Opened 4 years ago

Closed 4 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:

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 4 years ago by while0pass

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Type changed from Uncategorized to Bug

comment:2 Changed 4 years ago by aaugustin

  • Easy pickings unset
  • Resolution set to duplicate
  • Status changed from new to closed

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

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