This looks like a foreign key relationship (probably should be if it's
not). Use ModelChoiceField instead of ChoiceField. I haven't used it
manually in a form before, but try this:

instrument = ModelChoiceField(queryset=Instrument.objects.all(),
cache_choices=False, required=False)

Note that this will return the primary key of an instrument for the
value, rather than the name.

----
Nathan Ostgard

On Jul 10, 4:41 am, AnaReis <[EMAIL PROTECTED]> wrote:
> Hi,
> I have a form on my project which has a drop down list with several
> options that are loaded from a table in a database.
> The code is this:
>
> class ProductForm(forms.Form):
>     instrument_Name=ChoiceField(required=False,
> choices=[(i.instrument_name,i.instrument_name) for i in
> Instrument.objects.all()])
>
> The problem is that whenever I add a new instrument to the instrument
> table the instrument only appears on the drop down list if I restart
> the server or after an hour (more or less) of when I added the
> instrument.
> I would like to know what can I do to make a new instrument appear on
> the drop down list as soon as it is added, or what am I doing wrong.
> Ana


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to