On 23 Kwi, 15:44, hoamon <[EMAIL PROTECTED]> wrote:
> Hi there~
>
> I have a ChoiceField() of [newforms] in CancelForm,
> it's choices list is depending on database table sign2.
> my source code is below.
>
> --
> from django import newforms as forms
> class CancelForm(forms.Form):
> U_hash = {}
> for U in Sign2.objects.all():
> U_hash[U.unit.id] = U.unit.name
>
> Units = [('', '')]
> for (key, value) in U_hash.items():
> unit = (key, value)
> Units.append(unit)
>
> name = forms.CharField(label="name", max_length=10)
> no = forms.CharField(label="personalid", max_length=10)
> unit = forms.ChoiceField(label="unitname", choices=Units)
> --
>
> The problem is:
> When start apache server, the sign2 table only have two unit's
> records. after some minutes, may be the unit's records grows, but the
> CancelForm only have two choices. I must restart apache server to
> renew the CancelForm.
>
> thanks for your patience.
You may want to look at ModelChoiceField(), look at:
http://code.djangoproject.com/browser/django/trunk/django/newforms/models.py
--
Robert
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---