Django is giving me some runtime warnings (on code that I didn't write).
How can I get Django to give me a stacktrace, so I can see what is causing these?
/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py:808:
RuntimeWarning: DateTimeField received a naive datetime (2012-07-19 09:36:16.161479)
while time zone support is active.
RuntimeWarning
We call them "naive" because this datetime representation does not have a time zone. This means the datetime may not actually exist in certain areas in the world even though it is valid. For example, when daylight saving changes are applied by a region, the clock typically moves forward or backward by one hour.
Time zone support is disabled by default. To enable it, set USE_TZ = True in your settings file. In Django 5.0, time zone support will be enabled by default. Time zone support uses zoneinfo , which is part of the Python standard library from Python 3.9.
For DateField : default=date.today - from datetime.date.today() For DateTimeField : default=timezone.now - from django.utils.timezone.now()
From the docs at: https://docs.djangoproject.com/en/stable/topics/i18n/timezones/#code
During development, you can turn such warnings into exceptions and get a traceback by adding the following to your settings file:
import warnings
warnings.filterwarnings(
'error', r"DateTimeField .* received a naive datetime",
RuntimeWarning, r'django\.db\.models\.fields')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With