Opened 6 years ago

Last modified 3 months ago

#11028 new Bug

Problem with searching in m2m fields in inherited model

Reported by: vitek_pliska Owned by: albertoconnor
Component: contrib.admin Version: master
Severity: Normal Keywords: admin search inheritance
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

Models:

class Publishable(models.Model):
    ...
    authors = models.ManyToManyField(Author, verbose_name=_('Authors'))

class Article(Publishable):
    ...

and admin options like these:

class PublishableAdmin(admin.ModelAdmin):
    ...
    search_fields = ('title', 'description', 'slug', 'authors__name', 'authors__slug',)

class ArticleAdmin(PublishableAdmin):
    ...

Now, if we try search articles in admin, got this error:

ProgrammingError at /newman/articles/article/

invalid reference to FROM-clause entry for table "core_publishable"
LINE 1: ...") LEFT OUTER JOIN "core_publishable_authors" ON ("core_publ...
                                                             ^
HINT:  Perhaps you meant to reference the table alias "t3".

Attachments (1)

test11028.diff (2.2 KB) - added by albertoconnor 3 months ago.
Patch to add a negative test case for bisecting

Download all attachments as: .zip

Change History (9)

comment:1 Changed 6 years ago by Alex

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 4 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:3 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:4 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:5 Changed 3 months ago by albertoconnor

  • Owner changed from nobody to albertoconnor
  • Status changed from new to assigned

Changed 3 months ago by albertoconnor

Patch to add a negative test case for bisecting

comment:6 Changed 3 months ago by albertoconnor

bisecting showed that the issue was fixed in cf70c96ce08bec8834ada695451cc915f7558dbd.

It isn't clear if there is a regression test in that commit, it is possible another test catches it though.

comment:7 Changed 3 months ago by albertoconnor

  • Resolution set to fixed
  • Status changed from assigned to closed

Since I was unable to find a regression test I added a test in PR: https://github.com/django/django/pull/4517.

comment:8 Changed 3 months ago by timgraham

  • Has patch set
  • Patch needs improvement set
  • Resolution fixed deleted
  • Status changed from closed to new

Please don't close a ticket until the patch is committed.

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