Opened 9 years ago

Closed 9 years ago

#15839 closed Bug (duplicate)

search_fields: duplicated search results when following relationships "backward"

Reported by: while0pass 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: no


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:

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

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

Change History (2)

comment:1 Changed 9 years ago by while0pass

Type: UncategorizedBug

comment:2 Changed 9 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