Looking at the source, ModelChoiceField validates the given id against
the initial queryset, where you provided an empty one.
"models.Gallery.objects.none()"
So no id's validate. I think changing none() to all() should make it
work.

TiNo

On Jun 26, 9:01 pm, mwebs <[EMAIL PROTECTED]> wrote:
> Hello,
> I have a serious validation problem with a form using a
> ModelSchoiceField.
>
> Forms:
>
> class MyModelChoiceField(forms.ModelChoiceField):
>     def label_from_instance(self, obj):
>         return "%s" % obj.name
>
> class PictureForm(forms.Form):
>     image          = forms.ImageField(label='Picture')
>     gallery        = MyModelChoiceField(models.Gallery.objects.none(),
> empty_label=None)
> __________________________________________________
>
> View:
> picture_form = forms.PictureForm()
> picture_form.fields['gallery'].queryset = Gallery.objects.filter(...)
>
> It displays all fine, my ModelchoiceField has all Gallery-Entries I
> pass.
> But when it comes to validation an ValidationError is raised.
>
> I cannot understand this at all. Everthing is properly passed to the
> server.
> request.POST['gallery']  is the right Gallery-id, everthing seems fine
> but it does not work.
>
> Please help me, these ModelChoiceField drive me crazy!
>
> 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