Django FOrms

8 views
Skip to first unread message

prem

unread,
Mar 23, 2012, 5:41:26 PM3/23/12
to Django users
I'm using Django forms and need to create a list box.

What would be the equivalent of listbox in Django form fields?

Here is my code snippet,

Models.py

class Volunteer(models.Model):
NO_OF_HRS = (('1','1') ('2','2'))
datecreated = models.DateTimeField()
volposition = models.CharField(max_length=300)
roledesc = models.CharField(max_length=300)
Duration = models.CharField(choices=NO_OF_HRS,max_length=1)**
forms.py

class VolunteerForm(forms.ModelForm)
datecreated = forms.DateField(label=u'Creation Date')
volposition = forms.CharField(label=u'Position Name',
max_length=300)
roledesc = forms.roledesc(label=u'Role
description',max_length=5000)
Duration =
forms.CharField(widget=forms.select(choices=NO_OF_HRS),max_length=2)

When I try to run, I get the following error,

NO_OF_HRS is not defined

dummyman dummyman

unread,
Mar 23, 2012, 11:58:16 PM3/23/12
to django...@googlegroups.com
Hi, u ve not inserted comma after a first entry in the tuple NO_OF_HRS


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Reply all
Reply to author
Forward
0 new messages