Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#18530 closed Bug (fixed)

Inconsistent error handling on admin filter url's

Reported by: david@… Owned by: Julien Phalip
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 Phalip 4 years ago.
18530-admin-filter-incorrect-lookup.diff (3.1 KB) - added by Julien Phalip 4 years ago.

Download all attachments as: .zip

Change History (8)

Changed 4 years ago by Julien Phalip

Attachment: 18530.admin-filter-500.diff added

comment:1 Changed 4 years ago by Julien Phalip

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: worksforme
Status: newclosed

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 4 years ago by david@…

Resolution: worksforme
Status: closedreopened

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 4 years ago by Julien Phalip

comment:3 Changed 4 years ago by Julien Phalip

Has patch: set
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

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 4 years ago by Julien Phalip

Owner: changed from nobody to Julien Phalip
Status: reopenednew

I'll try and get that committed soon.

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

Resolution: fixed
Status: newclosed

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 4 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