开发者

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

开发者 https://www.devze.com 2023-02-02 18:35 出处:网络
I have records with a timestamp field, and I\'d like to 开发者_如何学Pythonfilter their Django admin view by datetime ranges.

I have records with a timestamp field, and I'd like to 开发者_如何学Pythonfilter their Django admin view by datetime ranges.

I'm looking for something like adding to the url ?timestamp__lt=201012310715&timestamp__gte=201012300715

^ this doesn't work..

Any ideas? Thanks!


I think it works if you specify the datetime in the following format:

YYYY-MM-DD HH:MM:SS

The query string would then look something like:

?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 is working and if this will continue to work like this in future releases.

0

精彩评论

暂无评论...
验证码 换一张
取 消