Opened 14 years ago

Closed 14 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

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

Type: UncategorizedBug

comment:2 by Aymeric Augustin, 14 years ago

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