Django admin: how to filter records by datetime ranges using the GET url parameter?

I have entries with a timestamp field, and I would like to filter their admin view in Django by datetime ranges.

I'm looking for something like adding in url ?timestamp__lt=201012310715×tamp__gte=201012300715

^ this does not work.

Any ideas? Thanks!

+6
django django-admin
source share
1 answer

I think this works if you specify a date-time in the following format:

YYYY-MM-DD HH:MM:SS

The query string will look something like this:

?datetime_field__lt=2010-09-28+21:00:59&datetime_field__gt=2010-09-22+00:00:00

Actually, I have no idea why only this format works, and if it will continue as in future releases.

+7
source share

All Articles