This may sound like a cop out, but why can't you create a gallery
object with that default value.
Then when you construct your query set, you can create so that that
default option is returned. This
would enable you to both display the correct option, as well as work
during the validatio step.

-Regards
Adi

On Jun 26, 12:27 pm, mwebs <[EMAIL PROTECTED]> wrote:
> 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 [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