5

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?

1 Answer 1

1

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.

2
  • I didn't. Actually I gave up because one client had the issue one time. I'll upgrade Gappelli to see if they fixed it (my issue was only in the admin itself) and try to patch it myself and make some pull request. Thanks for the info Oct 20, 2016 at 11:46
  • As the author of the above mentioned article I feel the need to add my two cents. This error indicates and issue with the data in the DB, so hacking the Django core itself is more of a ugly patch that may turn pretty ugly some day. As there is no details about the exception (stracktrace/etc.) it is hard to say, but maybe the better position for the fix is in grapelly itself. Actually I am missing the part why is make_aware called? Oct 20, 2016 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.