Search by date range in Django Admin


After trying to include two input fields (for date range) into the search form in Django Admin for days and with no avail, I finally have done so by appending the form itself using jQuery, resulting in this:

When the submit button is hit without filling out those two fields, the form returns an ?e=1 error, which is a problem number one:

When dates are properly filled out the form works as expected:

But then when I submit the form with different dates (or empty dates as shown in the example below), the URL parameters are doubled, and the original input is always there rendering the usage of the form useless, which is a problem number two:

How can I fix both of those problems, one: be able to send an empty form, expecting that all entries will be returned in the search results, two: get rid of the orginal set of url parameters when the form is re-submitted?

Can I have little nudge in the right direction?

Ended up installing DateRangeFilter module and moving it into my core files. Then tweaked .html templates and the result was exactly what I wanted to achieve (also visually).


1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.