logo       

Dynamic Choices for ChoiceField: msg#02329

DjangoUsers

Subject: Dynamic Choices for ChoiceField


Hello,

I'm trying to make a form for data entry into my database that uses
ChoiceFields for foreign keys. Obviously, the ideal choice would be
ModelChoiceField, however I'm not using the django ORM, so I've
assumed that's not going to work (I'm using Elixir/SQLAlchemy).

I originally set the choices parameter in the ChoiceField declaration
to be derived from a query result from SQLAlchemy (returned as an
array of tuples). The problem is that the choices don't update when
the database changes. They are fixed to whatever was present when the
server is initialized (or at least it appears to be).

I've worked around this by using CharFields and implementing my own
validation method that checks for the value in the aforesaid query
result. Unforunately, that doesn't help me if i want to use the
forms.as_<html> methods.

I'm looking for suggestions/advice on to get the ChoiceField choices
to update when the form is the used.

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

<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise