Opened 5 years ago

Closed 5 years ago

#30354 closed Uncategorized (worksforme)

Filter not displayed when admin.RelatedOnlyFieldListFilter is used for auth.models.User

Reported by: rvernica Owned by: nobody
Component: Uncategorized Version: dev
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


In a model where a field is a foreign keys to auth.models.User, admin.RelatedOnlyFieldListFilter does not display a filter. Something like:

class Foo(models.Model):
  bar = models.ForeignKey(auth.models.User, on_delete=models.CASCADE)

And ModelAdmin uses RelatedOnlyFieldListFilter for the foreign key:

class FooAdmin(admin.ModelAdmin):
  list_display = ('bar',)
  list_filter = (('bar', admin.RelatedOnlyFieldListFilter),)

No filter is displayed in the UI in the right side-bar. No error message is displayed. If list_filter is changed to:

  list_filter = ('bar',)

It works as expected.

Change History (1)

comment:1 by Mariusz Felisiak, 5 years ago

Resolution: worksforme
Status: newclosed
Version: 2.1master

Everything works for me on the current master (checked at 49fb3f5f3ed8b37f2ae02d0fdc6980c4152c58e3). Maybe you have only one user related with Foo. List filter with only one value will not be displayed.

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