I upgraded to Django 1.7 recently, and I'm starting to see these timezone warnings on DateTime/Time fields when my local timezone differs from the server timezone when I view them in the admin interface. I definitely understand why they added this, and it remove a lot of ambiguity, especially with DateTime, but I have a TimeField that actually stores time respective to the logged-in user's timezone (as saved on their user profile), so the warning message is actually misleading in that case. I've also seen that it is indeed Django 1.7 that has added this functionality (see https://github.com/django/django/blob/master/django/contrib/admin/static/admin/js/admin/DateTimeShortcuts.js#L63 and https://docs.djangoproject.com/en/dev/releases/1.7/#admin-shortcuts-support-time-zones).
My question is how do I turn off these messages from showing? If so, is there a way I can specify how to hide the warnings on a per-field basis?
If you add a Media
class to your ModelAdmin
you can include a CSS file that makes those warnings disappear.
# admin.py
class MyModelAdmin(ModelAdmin):
model = MyModel
class Media(object):
css = {'all': ('no-more-warnings.css', )}
The created CSS file should include the following rule:
/* no-more-warnings.css */
.timezonewarning {
display: none;
}
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