I'm not sure of the intent, but something to keep in mind is that if
you have previously-valid information and wish to save it again, it
may become invalid.
For example, I have a list of "active" employees for selection in the
filtered choice field. If I open up some object and hit "Save" after
the employee is no longer active, this would incorrectly raise an
error. I would imagine this avoids it.

 -rob

On Aug 6, 10:00 pm, Nick <[EMAIL PROTECTED]> wrote:
> The clean() methods in both ModelChoiceField and
> ModelMultipleChoiceField use a block similar to the following in order
> to validate the selected choice:
>
> try:
>     value = self.queryset.model._default_manager.get(pk=value)
> except self.queryset.model.DoesNotExist:
>     raise ValidationError(ugettext(u'Select a valid choice. That
> choice is not one of the available choices.'))
>
> Is there any reason that shouldn't simply be
> self.queryset.get(pk=value) ?
>
> I came across this in a project when I was trying to work out why it
> was allowing choices that I had explicitly filtered out of the
> queryset - and of course this explains it. Is there a reason that the
> default manager should be used instead of just the original queryset?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to