Hello,

I try to set data for a ModelChoiceField() manually. This means the
data is not in my db, so it s not in a Queryset.

my form:

class PictureForm(forms.Form):
    image          = forms.ImageField(label='Picture')
    gallery        = MyModelChoiceField(models.Gallery.objects.none(),
empty_label=None)
-------------------------------------------------

If there are galleries I populate the modelChoiceField like this:

  [1]  picture_form.fields['gallery'].queryset =
Gallery.objects.filter(...)
-------------------------------------------

if ther are no Galleries I want to populate the modelChoiceField with
an entry "Default"

<option value="foo">Default</option>
------------------------------------
this Default-select-option I want to fill in manually, because it does
not exist in the DB.


because it works the [1]-way I thought about building a queryset
manually, but I could not figure out how to do this.
Can anyone please give me a short example how to build and fill a
queryset manually, or show me a more elegeant way how to populate the
modelchoicefield with data not comming from the database.

Thanks,Toni



--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
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