Alexei Martchenko
Alexei Martchenko

Reputation: 331

Django Admin NonExistentTimeError in date_hierarchy

I just got an error in Django Admin. This is the locally reproduced log:

NonExistentTimeError at /admin/{blah}/
2015-10-18 00:00:00
Request Method: GET Request
URL:    http://127.0.0.1:8000/admin/{blah}/?q=someuser%40hotmail.com
Django Version: 1.7.10
Exception Type: NonExistentTimeError
Exception Value:     2015-10-18 00:00:00 Exception
Location:   C:\Python27\lib\site-packages\pytz\tzinfo.py in localize,
line 327 Python Executable: C:\Python27\python.exe Python
Version:    2.7.10

I discovered that indeed 2015-10-18 00:00:00 does not exist in my Timezone ('America/Sao_Paulo') because that was when Daylight Savings started.

I'm using date_hierarchy = 'date_lastupdated' and when I searched in the admin for the user [email protected] Django returns only one record and this user's date_lastupdated is '2015-10-18 05:10:18.593336-03'.

The error happens in In template ~~~~/Python27/lib/site-packages/grappelli/templates/admin/change_list.html line 212:

<!-- DATE HIERARCHY -->
    {% block date_hierarchy %}
        {% if cl.date_hierarchy %}{% date_hierarchy cl %}{% endif %}
    {% endblock %}

So, Grappelli is trying to build only one time hierarcy fraction link up there in the admin listing, but it's not working

I was able to reproduce it in two machines (Linux and Windows), I upgraded PYTZ. Still happening in 2015.4 and 2015.6 versions.

Is this a known issue?

Upvotes: 5

Views: 515

Answers (1)

Jessica Ferrari
Jessica Ferrari

Reputation: 11

I don't know if you solve the problem yet. Hope you did. I was kind of desperate and found this solution:

http://www.ilian.io/django-pytz-nonexistenttimeerror-and-ambiguoustimeerror/

I edited the file in my env:

/myenv/lib/python2.7/site-packages/django/db/models/sql/compiler.py

and changed the code from line 1145 (the line that the error starts).

For me the second solution worked the best.

I know it's not the best option, but it was a quick fix just to keep the system going for a while.

Upvotes: 1

Related Questions