Closed pooyamb closed 6 years ago
@pooyamb I'm not doing much of python these days 😞
I would override AdminSplitjDateTime
decompress method for now
Since jdatetime is a separate project I rather not to change it because of django-jalali
I forked this project and made some changes to fix compatibility issues with new django version, can you check it before I make a pull request? you're more familiar with it. here is the link
Hey guys, i have this problem with admin page (JDateFieldListFilter) too!! what is the solution? Django : 1.11 , Python : 3.5
I fixed the timezone in master and drop support for Django 1.X.
If you need timezone please upgrade to Django 2.0
Hi, Why I try to set django's default timezone to non UTC timezones, ex. Asia/Tehran, I get an error in django admin changeform,
Assume this model :
And registering it with default modeladmin :
when I set default timezone in settings.py
Error details: Trace back :
After tracing the error(in django 1.11) I found out,
django_jalali.admin.widgets.AdminSplitjDateTime
inherits fromdjango.forms.SplitDateTimeWidget
,in
forms.SplitDateTimeWidget's
decompress
method, django tries to change field value to current timezone,to_current_timezone(forms.widgets:876)
in
to_current_timezone
method in forms.utils, if USE_TZ is set, it will try totimezone.make_naive
the datetime value(making the datetime, timezone unaware) so it callspytz
methods, there it will try to comparejdatetime
with native python'sdatetime
and error occurs,Posible solutions : The first solution I can think about is to override AdminSplitjDateTime's decompress method, but I don't know about backward incompatibility,
The second solution is to change jdatetime's behaviour in
__lt__
and other comparing methods to accept native's datetime objects.I should add that all this problems only happens when using
pytz
module, but as django 1.11,pytz
is now a required dependencyI'm waiting for your response to work on it,
Django version : 1.11 with pytz (also tested on 1.10 1.9 1.8) Python version : 3.5.2