Re: [Django] #1891: 'distinct':True no longer usable in limit_choices_to

100 views
Skip to first unread message

Django

unread,
May 7, 2012, 4:02:19 AM5/7/12
to django-...@googlegroups.com
#1891: 'distinct':True no longer usable in limit_choices_to
-------------------------------------+-------------------------------------
Reporter: mattimustang@… | Owner: nobody
Type: New feature | Status: reopened
Component: Database layer | Version:
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 1
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------

Comment (by anonymous):

[http://www.replicawatchesbuy.org.uk/ replica watches] races

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

Django

unread,
May 7, 2012, 12:03:14 PM5/7/12
to django-...@googlegroups.com
#1891: 'distinct':True no longer usable in limit_choices_to
-------------------------------------+-------------------------------------
Reporter: mattimustang@… | Owner: nobody
Type: New feature | Status: reopened
Component: Database layer | Version:
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 1
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by charettes):

* cc: charette.s@… (added)

Django

unread,
May 19, 2013, 7:20:37 AM5/19/13
to django-...@googlegroups.com
#1891: 'distinct':True no longer usable in limit_choices_to
-------------------------------------+-------------------------------------
Reporter: mattimustang@… | Owner: gcc
Type: New feature | Status: assigned

Component: Database layer | Version:
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 1
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by gcc):

* owner: nobody => gcc
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/1891#comment:23>

Django

unread,
May 19, 2013, 9:30:56 AM5/19/13
to django-...@googlegroups.com
#1891: ForeignKey with m2m filter can duplicate foreign model entries in
ModelForm/ModelChoiceField

-------------------------------------+-------------------------------------
Reporter: mattimustang@… | Owner: gcc
Type: Bug | Status: assigned

Component: Database layer | Version:
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 1
Has patch: 1 | Patch needs improvement: 0

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by gcc):

* needs_better_patch: 1 => 0
* type: New feature => Bug


Comment:

Created a patch and test in a [https://github.com/django/django/pull/1169
pull request].

--
Ticket URL: <https://code.djangoproject.com/ticket/1891#comment:24>

Django

unread,
Jun 5, 2013, 9:42:17 AM6/5/13
to django-...@googlegroups.com
#1891: ForeignKey with m2m filter can duplicate foreign model entries in
ModelForm/ModelChoiceField
-------------------------------------+-------------------------------------
Reporter: mattimustang@… | Owner: gcc
Type: Bug | Status: assigned
Component: Database layer | Version:
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1

Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* needs_docs: 1 => 0
* needs_better_patch: 0 => 1


Comment:

I don't think the overhead of applying `distinct` in cases where it's not
needed is ideal. We should either add logic so that it's not called when
it's not needed (as suggested by Malcolm above), or implement a solution
that will solve this by allowing a custom queryset to be used for choices
(e.g. #13181 or #2445).

--
Ticket URL: <https://code.djangoproject.com/ticket/1891#comment:25>

Django

unread,
Dec 11, 2013, 10:32:46 AM12/11/13
to django-...@googlegroups.com
#1891: ForeignKey with m2m filter can duplicate foreign model entries in
ModelForm/ModelChoiceField
-------------------------------------+-------------------------------------
Reporter: mattimustang@… | Owner: gcc
Type: Bug | Status: assigned
Component: Database layer | Version:
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 1
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Fak3):

* cc: someuniquename@… (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/1891#comment:26>

Django

unread,
Apr 4, 2019, 8:13:28 PM4/4/19
to django-...@googlegroups.com
#1891: ForeignKey with m2m filter can duplicate foreign model entries in
ModelForm/ModelChoiceField
-------------------------------------+-------------------------------------
Reporter: mattimustang@… | Owner: Chris
| Wilson

Type: Bug | Status: assigned
Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Josh):

Can we add an optional keyword argument to conditionally apply the
DISTINCT select? This just bit me on a production app.

Maybe something like:

{{{
account_manager = models.ForeignKey(
User,
limit_choices_to=Q(groups__name='Sales') | Q(groups__name='Admin'),
limit_choices_distinct=True, # default False
)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/1891#comment:27>

Django

unread,
Oct 27, 2020, 7:51:53 AM10/27/20
to django-...@googlegroups.com
#1891: ForeignKey with m2m filter can duplicate foreign model entries in
ModelForm/ModelChoiceField
-------------------------------------+-------------------------------------
Reporter: mattimustang@… | Owner: Crowley
| Shaita

Type: Bug | Status: assigned
Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* owner: Chris Wilson => Crowley Shaita


* needs_better_patch: 1 => 0

* stage: Accepted => Ready for checkin


Comment:

[https://github.com/django/django/pull/13315 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/1891#comment:28>

Django

unread,
Oct 27, 2020, 4:10:55 PM10/27/20
to django-...@googlegroups.com
#1891: ForeignKey with m2m filter can duplicate foreign model entries in
ModelForm/ModelChoiceField
-------------------------------------+-------------------------------------
Reporter: mattimustang@… | Owner: Crowley
| Shaita
Type: Bug | Status: closed

Component: Database layer | Version:
(models, ORM) |
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"556fa4bbba5ba86bc1646a86fb11ab55405d4aa4" 556fa4bb]:
{{{
#!CommitTicketReference repository=""
revision="556fa4bbba5ba86bc1646a86fb11ab55405d4aa4"
Fixed #1891, Fixed #11707 -- Prevented duplicates with limit_choices_to on
multi-value relations.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/1891#comment:29>

Reply all
Reply to author
Forward
0 new messages