当我访问我的网址时,我只得到:<django.forms.fields.ChoiceField object at 0x026D1CD0>
我想要数字 Choicefield
我的models.py
应用程序中有以下内容:
from django.db import models
from django.forms import ModelForm
class Zonas(models.Model):
name = models.CharField(max_length=30)
def __unicode__(self):
return self.name
class ZonasForm(ModelForm):
class Meta:
model = Zonas
我想问题出在我的views.py
:
from django import forms
from testApp.models import Zonas
from django.shortcuts import render_to_response
def menuForm (request):
z = list (Zonas.objects.all())
numbers = forms.ChoiceField(z)
return render_to_response('hello.html', {'numbers':numbers})
menuForm 用于我urls.py
的 as:
from django.conf.urls import patterns, include, url
from testApp.views import menuForm
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^hello/$', menuForm ),
)
我的html
页面尽可能简单:
<html>
<body>
{{numbers}}
</body>
</html>
任何帮助表示赞赏