#15819: Admin searches should use distinct, if query involves joins
-------------------------------------+-------------------------------------
Reporter: Adam | Owner: aip@…
Kochanowski <aip@…> | Status: reopened
Type: Bug | Component: contrib.admin
Milestone: | Severity: Normal
Version: 1.3 | Keywords:
Resolution: | Has patch: 0
Triage Stage: | Needs tests: 0
Unreviewed |
Needs documentation: 0 |
Patch needs improvement: 0 |
-------------------------------------+-------------------------------------
Comment (by ryankask):
Yes, by the looks of those tickets it doesn't always seem simple.
I checked with 1.2.5 and the original ticket reporter is right in the
behavior changed from 1.2.5 to 1.3 (I think with the patch for #13902).
Just to clarify the behavior: I created a little app called `alias` with
model like:
models.py:
{{{#!python
class Alias(models.Model):
user = models.ForeignKey(User)
first_name = models.CharField(max_length=36)
last_name = models.CharField(max_length=36)
}}}
admin.py:
{{{#!python
class MyUserAdmin(UserAdmin):
search_fields = ('username', 'first_name', 'last_name', 'email',
'alias__first_name', 'alias__last_name')
}}}
with a fixture like:
{{{
[{"pk": 1, "model": "alias.alias", "fields": {"first_name": "ryan",
"last_name": "jones", "user": 1}},
{"pk": 2, "model": "alias.alias", "fields": {"first_name": "ryan",
"last_name": "smith", "user": 1}}]
}}}
... a search of ``/admin/auth/user/?q=ryan+smith`` returns the same User
twice.
Would it be possible to add an option to `ModelAdmin` that forced
`distinct()` to be called on a search?
--
Ticket URL: <http://code.djangoproject.com/ticket/15819#comment:5>
Django <http://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.