Opened 8 years ago

Last modified 20 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 20 months ago.
Patch to add a negative test case for bisecting

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:2 Changed 6 years ago by Julien Phalip

Severity: Normal
Type: Bug

comment:3 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:4 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:5 Changed 20 months ago by albertoconnor

Owner: changed from nobody to albertoconnor
Status: newassigned

Changed 20 months ago by albertoconnor

Attachment: test11028.diff added

Patch to add a negative test case for bisecting

comment:6 Changed 20 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 20 months ago by albertoconnor

Resolution: fixed
Status: assignedclosed

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 20 months ago by Tim Graham

Has patch: set
Patch needs improvement: set
Resolution: fixed
Status: closednew

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

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