#11707: limit_choices_to on a ForeignKey can render duplicate options in 
formfield
-------------------------------------+-------------------------------------
     Reporter:  Chris.Wesseling@…    |                    Owner:
         Type:  Bug                  |  charstring
    Component:  Forms                |                   Status:  new
     Severity:  Normal               |                  Version:  SVN
     Keywords:  ForeingKey           |               Resolution:
  limit_choices_to, dceu2011         |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by anonymous):

 Replying to [comment:19 jacob]:
 > Discussion from IRC:
 > {{{
 > [09:26am] jacobkm: It also needs additions to documentation to mention
 that Q() objects are acceptable in limit_choices_to.
 > }}}

 
[https://docs.djangoproject.com/en/1.3/ref/models/fields/#django.db.models.ForeignKey.limit_choices_to
 Documentation] on ForeignKey.limit_choices_to already mentions: "Instead
 of a dictionary this can also be a Q object for more complex queries."

 Further discussion:
 {{{
 17:00 < chars> jacobkm: The only known case that broke the original
 .distinct()
                solution was in Postgres. So maybe if #6422 gets accepted,
 we
                could test for the distinct_on_fields feature and then
 distinct
                on the pk, which is unique by definition.
 17:00 < jacobkm> chars: see now *that* makes me a lot happier.
 17:00 < chars> And fallback to the vanilla .distinct() if the backend
 doesn't
                support it.
 }}}

 That's #6422.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/11707#comment:20>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en.

Reply via email to