admin date filter problem

77 views
Skip to first unread message

Daniel Provin

unread,
Jun 20, 2007, 5:17:44 PM6/20/07
to django...@googlegroups.com
Hello
I notice that the admin has a problem when filtering dates
I tried:
http://localhost/admin/app/model/?date__lte=2007-06-21
and it generates the same results as:
http://localhost/admin/app/model/?date__lt=2007-06-21
so the LTE filter (less than or equal) is giving the same results as the LT (less than only) filter for dates fields (datetime actually)

the GTE (greater than or equal) and GT (greater than only) works fine and using the shell from manage.py and filtering using Model.objects.filter(date__lte='2007-06-21) everything works, so I think it is an admin only problem.

should I register a ticket? (or is it a ticket only for when I already have the patch?)

Daniel

--
--

pro...@gmail.com

unread,
Jun 20, 2007, 5:39:46 PM6/20/07
to Django users
I had some doubts about my testing because my fields are datetime.
So I tested it some more and the same problem came up but not only on
the admin

I have an app with a datetime field. Then I saved enoght objects to
have one for each day of the month and the same results came up for:
App.objects.filter(date__gt=datetime.datetime(2007, 5, 21, 0, 0, 0))
or
App.objects.filter(date__gte=datetime.datetime(2007, 5, 21, 0, 0, 0))
also the same results for LTE or LT

its it my mistake somewhere? or is it a bug?

Daniel

Malcolm Tredinnick

unread,
Jun 20, 2007, 8:03:36 PM6/20/07
to django...@googlegroups.com
On Wed, 2007-06-20 at 21:39 +0000, pro...@gmail.com wrote:
> I had some doubts about my testing because my fields are datetime.
> So I tested it some more and the same problem came up but not only on
> the admin
>
> I have an app with a datetime field. Then I saved enoght objects to
> have one for each day of the month and the same results came up for:
> App.objects.filter(date__gt=datetime.datetime(2007, 5, 21, 0, 0, 0))
> or
> App.objects.filter(date__gte=datetime.datetime(2007, 5, 21, 0, 0, 0))
> also the same results for LTE or LT
>
> its it my mistake somewhere? or is it a bug?

We've fixed some tickets related to this in the past. I cannot remember
off the top of my head if there is still one open or not. Make sure the
problem is repeatable with the latest subversion code and the database
backend you are using will probably be significant, too. Most of the
problems that have been reported have been with SQLite (or caused by
trying to fix SQLite issues).

So django version, database backend and Python version (because Python
2.5 uses the builtin SQLite driver) are probably all relevant if you
open a ticket. But have a search in the database component (just scan
through the titles of all the open tickets in that component) first to
see if it's a dupe.

Regards,
Malcolm


Michael Trier

unread,
Jun 20, 2007, 8:06:23 PM6/20/07
to django...@googlegroups.com
Any chance your field name is causing you problems? Look at the generated sql.

Michael

Michael Trier

unread,
Jun 20, 2007, 8:07:46 PM6/20/07
to django...@googlegroups.com
NM, just saw Malcolm's post.

Michael

pro...@gmail.com

unread,
Jun 21, 2007, 2:03:39 PM6/21/07
to Django users
I am using MySQL, last subversion for django and Python 2.4.4 on
debian linux
Tested some more with date fields and it all working fine, the problem
was with datetime fields and it was my fault because I did not include
the time.

Daniel

On Jun 20, 9:03 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:

Reply all
Reply to author
Forward
0 new messages