Opened 6 years ago

Closed 6 years ago

#15839 closed Bug (duplicate)

search_fields: duplicated search results when following relationships "backward"

Reported by: Andrei Khitrov Owned by: nobody
Component: contrib.admin Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX:

Description

If in search_fields one uses both fields of a model A and a model B related to A as many to one (B has a foreign key field to A), search results for A-objects may contain multiple occurrence of the same A-object.

Example code:

# models.py
class DictionaryEntry(models.Model):
  ...
  transcription = models.CharField(...)
  ...

class OrthographicVariant(models.Model):
  entry = models.ForeignKey(DictionaryEntry, related_name='orthvars')
  orthvar = models.CharField(...)
  ... 
# admin.py
class AdminDictEntry(admin.ModelAdmin):
  ...
  search_fields = ('transcription', 'orthvars__orthvar')
  ...

Change History (2)

comment:1 Changed 6 years ago by Andrei Khitrov

Type: UncategorizedBug

comment:2 Changed 6 years ago by Aymeric Augustin

Easy pickings: unset
Resolution: duplicate
Status: newclosed

This ticket looks very much like #15819, where a discussion has already started.

Note: See TracTickets for help on using tickets.
Back to Top