Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#18530 closed Bug (fixed)

Inconsistent error handling on admin filter url's

Reported by: david@… Owned by: julien
Component: contrib.admin Version: 1.4
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This probably isn't officially supported but there is a curious change to error handling introduced in Django 1.4.

In 1.3 something like

/admin/app/model/?date__gte=moo

would yield e=1 and no 500 error

In 1.4 I get a 500 instead. But only for dates!

?id__gte=moo

yields a e=1

Perhaps this type of hard filtering should just be scorned all together. But I do find it quite useful and a 500 error in such particular situations is odd behavior. I've implemented a hack start and end date filter which is why I've gotten this. Ugly I know.

Attachments (2)

18530.admin-filter-500.diff (1.4 KB) - added by julien 3 years ago.
18530-admin-filter-incorrect-lookup.diff (3.1 KB) - added by julien 3 years ago.

Download all attachments as: .zip

Change History (8)

Changed 3 years ago by julien

comment:1 Changed 3 years ago by julien

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

I can't seem to reproduce the problem. See the attached patch, where the test passes.

If you can provide a failing test, please do reopen this ticket. Thanks!

comment:2 Changed 3 years ago by david@…

  • Resolution worksforme deleted
  • Status changed from closed to reopened

It appears linked to having a list_filter on the tested date such as
list_filter = date?

In the django regression test you linked, try changing admin.py

class ThingAdmin(admin.ModelAdmin):
    list_filter = ('color__warm', 'color__value')

to

class ThingAdmin(admin.ModelAdmin):
    list_filter = ('color__warm', 'color__value', 'date')

then you should get the error.

Changed 3 years ago by julien

comment:3 Changed 3 years ago by julien

  • Has patch set
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

I've attached a suggested fix. I'll let someone else review it, and if that's fine then I'll also backport it to 1.4.x to address this small regression.

comment:4 Changed 2 years ago by julien

  • Owner changed from nobody to julien
  • Status changed from reopened to new

I'll try and get that committed soon.

comment:5 Changed 2 years ago by Julien Phalip <jphalip@…>

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

In 336dfc3413b22bc5a5008bba7ff383886da96d60:

[1.4.X] Fixed #18530 -- Fixed a small regression in the admin filters where wrongly formatted dates passed as url parameters caused an unhandled ValidationError. Thanks to david for the report.

comment:6 Changed 2 years ago by Julien Phalip <jphalip@…>

In c555741aa7840d8ee4b3a191550924cca6f27105:

Fixed #18530 -- Fixed a small regression in the admin filters where wrongly formatted dates passed as url parameters caused an unhandled ValidationError. Thanks to david for the report.

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