To populate select field you have many options.
First is using ModelChoiceField.
The ModelChoiceField have an argument named queryset, you can use like this
example
provincia = forms.ModelChoiceField(queryset=Provincia.objects.all() ......)

If you can't have a FK of Provincia table you can use a Choice Field and
populate externaly like this

provincia = forms.ChoiceField( ... )

and inside the form declare a new method named populate(self,
list_of_provincias):   (for example)
and inside this method you can do this...

self.fields['provincia'].choices = list_of_provincias

In other situations you can populate a ModelcoiceField externaly too:
example: You need to populate a modelchoice field with a queryset depending
in the user loged ...

def populate(self,user):
self.fields['boards'].queryset = Board.objects.filter( guild =
Guild.objects.get(owner=user) )

When you create a form yo need to call the .populate method with
request.user as argument.




2008/11/1 Rock <[EMAIL PROTECTED]>

>
> In brief, your forms field for province does not have to have anything
> to do with your corresponding model field.
> Just make a forms.ChoiceField with the data filled in that you need
> (or else look up the pattern for loading dynamic data into a
> forms.ChoiceField and do something like that.) If you go the dynamic
> route, make sure your form gets initialized properly when you create
> it for initial use and also when you create it for POST processing.
>
>
> >
>


-- 
neo2001[at]gmail.com
neo[at]art-xtreme.com

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