slashmili / django-jalali Goto Github PK
View Code? Open in Web Editor NEWJalali DateField support for Django model
Home Page: http://pypi.python.org/pypi/django_jalali
License: BSD 3-Clause "New" or "Revised" License
Jalali DateField support for Django model
Home Page: http://pypi.python.org/pypi/django_jalali
License: BSD 3-Clause "New" or "Revised" License
Please provide your configurations and softwares version
Hi
I do steps untill this step:
$ LC_ALL=fa_IR python manage.py runserver
when I run this code, I get it:
roshana@roshana ~/jalali $ LC_ALL=fa_IR python manage.py runserver Performing system checks... System check identified no issues (0 silenced). March 15, 2017 - 07:05:47 Django version 1.10.6, using settings 'jalali.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
and when I wrote the last step, I get thiss error:
Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 367, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 316, in execute settings.INSTALLED_APPS File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 53, in __getattr__ self._setup(name) File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 41, in _setup self._wrapped = Settings(settings_module) File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 97, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/roshana/jalali/jalali/settings.py", line 114, in <module> locale.setlocale(locale.LC_ALL, "fa_IR") File "/usr/lib/python2.7/locale.py", line 579, in setlocale return _setlocale(category, locale) locale.Error: **unsupported locale setting**
I get this error in python 2.7 & 3.4 , django 1.10
what should I do??
hi,
When I run the program ,I received with the following message:
*ImportError: No module named 'django.contrib.admin.filterspecs'
*
I think the relevant filterspecs module has been removed in the new version.
excuse me , have u delete the project https://github.com/slashmili/freeIBS/
?
if not, could u opensource it and i want to fork it.
thank u very much!
سلام
من به یک ویدجت نیاز دارم که وقتی رو فیلد تاریخ کلیک کردم باز شه!
چندتا گرفتم اما نشد و همینطور برنامه شما هم با جنگو 1.5 مشکل داره.
ممنون میشم که کمکم کنید.
I would like to write test and be able to run it against different version of django
hi
i want to use jalali date in forms , what should i replace this code ?
date = forms.DateField(widget=forms.SelectDateWidget())
Hi
when I add django_jalali to my project,just adding!
INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.sitemaps', 'django.contrib.staticfiles', 'django.contrib.messages', 'django.contrib.humanize', 'django.contrib.gis', 'django_jalali',
I get this error:
Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/handlers.py", line 67, in call return self.application(environ, start_response) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in call self.load_middleware() File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 47, in load_middleware mw_instance = mw_class() File "/usr/local/lib/python2.7/dist-packages/django/middleware/locale.py", line 24, in init for url_pattern in get_resolver(None).url_patterns: File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 365, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 360, in urlconf_module self._urlconf_module = import_module(self.urlconf_name) File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module import(name) File "/home/geonode/geonode/geonode/urls.py", line 37, in <module> admin.autodiscover() File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/init.py", line 29, in autodiscover import_module('%s.admin' % app) File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module import(name) File "/usr/local/lib/python2.7/dist-packages/django_jalali/admin/init.py", line 6, in <module> from .filters import JDateFieldListFilter File "/usr/local/lib/python2.7/dist-packages/django_jalali/admin/filters.py", line 4, in <module> from django.contrib.admin.utils import prepare_lookup_value ImportError: No module named utils
I really don't know what should I do with this error!
It seem when I add django_jalali to project the core of django conflict with django_jalali, although I'm not sure about it!
I want to know why this error occurs and how can solve it.
thank you for helping me!
I have got error from south at schemamigration.
Command:
python manage.py schemamigration --auto
Result:
! Cannot freeze field 'testApp.base.expire'
! (this field has class django_jalali.db.models.jDateTimeField)
! South cannot introspect some fields; this is probably because they are custom
! fields. If they worked in 0.6 or below, this is because we have removed the
! models parser (it often broke things).
! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork
Hi, I use djnagi-jalali with python 3 , everything is working well (such as templates) but 2 issues:
1- the datepicker widget is still in Gregorian. So I have to choose the date in Gregorian and then convert it to jalali with template.
2- I got locale.Error when I try to import Farsi locale in setting.py
I need to show date like this:
سهشنبه، ....
But formatting doesn't accept "،" (Persian comma). I think it needs utf-8 encoding.
Thank you very much.
Please provide your configurations and softwares version
when show time in template like {{ value.time }} the time is not local im in iran and it have 4:30 hours behind
Cannot extract the month using Extract() in annotation. Throws the error:
'Extract input expression must be DateField, DateTimeField, ' ValueError: Extract input expression must be DateField, DateTimeField, TimeField, or DurationField.
In admin
when i use jdatetime and datetime together Jalali datepicker works but Gregorian datepicker has problem and not work properly.
is there any way to use this package without changing the model's object manager? (i.e. objects = jmodels.jManager()
)
how to use your widget in form ?
SubfieldBase
is no longer accessible in Django 1.10+.
Could you fix this?
Hey,
I think it is a js problem, specifically jDateTimeShorts.js problem, where you Return False;
When you have an inline, adding another field ( that contains jDateField ) will retrun False (new version void(0) ) although it should add another Calendar, If you look through the Django DateTimeShortcuts.js you can see in DateTimeShortcuts.js ( django ):
cal_link.setAttribute('href', 'javascript:DateTimeShortcuts.openCalendar(' + num + ');');
but in jDateTimeShortcuts.js (django-jalali ):
shortcuts_span.setAttribute('href', 'javascript:void(0)');
if you have stackedInline or other inlines, where you add another field that contains date, nothing appears, only the default existing tab will work.
I'm not a js pro, if you have a solution let me know.
tnx
The idea is to let django_jalali
uses Django locale rather than system level locale when printing dates.
Given these settings
....
# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/
LANGUAGE_CODE = 'fa-ir'
TIME_ZONE = 'Asia/Tehran'
USE_I18N = True
USE_L10N = True
USE_TZ = True
MIDDLEWARE = [
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'reversion.middleware.RevisionMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
]
....
And this change:
diff --git a/django_jalali/templatetags/jformat.py b/django_jalali/templatetags/jformat.py
index fe265e6..3524ad8 100644
--- a/django_jalali/templatetags/jformat.py
+++ b/django_jalali/templatetags/jformat.py
@@ -1,5 +1,6 @@
from distutils.version import StrictVersion
import django
+from django.utils.translation import to_locale, get_language
import sys
from datetime import datetime, date
import jdatetime
@@ -16,6 +17,7 @@ register = Library()
@register.filter(expects_localtime=True, is_safe=False)
def jformat(value, arg=None):
"""Formats a date or time according to the given format."""
+ jdatetime.set_locale(to_locale(get_language()))
if value in (None, ''):
return ''
if arg is None:
It does work in some cases. However if the user has messed up locale settings in browser or user is from outside of Iran with different browser settings, Django get_language
function returns en
or de
or any other locale and the date is going to be printed in English.
Hi.
I want to use this wonderful package but when I want to retrieve data from database from mysql database I get this message:
λ Alis-iMac src → λ git master* → python manage.py dumpdata
CommandError: Unable to serialize database: global name 'datetime_safe' is not defined
I hope you can help me to fix the problem.
Thanks for fantastic package,
It would be great if it shows numbers as Persian.
Thanks a lot.
Hi
when I add django_jalali to my installed app I get the following error
AttributeError: 'module' object has no attribute 'SubfieldBase'
i just try to use in django 1.8
django error on
import django_jalali.admin.filterspecs
from django.contrib.admin.filterspecs import FilterSpec
ImportError: No module named filterspecs
by comment line in admin datepicker doesn`t exist any longer ...
Please provide your configurations and softwares version
File "/Users/nic/Desktop/goshnamone/api/models.py", line 75, in User
last_sms = jmodels.jDateTimeField(defualt=timezone.now,blank=True,verbose_name=_("last_sms"))
File "/Users/nic/Library/Python/2.7/lib/python/site-packages/django_jalali/db/models.py", line 197, in __init__
models.Field.__init__(self, verbose_name, name, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'defualt'
django_jalali date time field does not support default argument.
I do all steps, but when i want to add 30th of second month, i have a valid error, (becouse second months doesn't accenp 30)
i add filterspecs.py todjango 1.7, becouse it doesn't work without this file, but it doesn't work.
Django: 1.11.4
Python: 3.6.1
When I set timezone to "Asia/Tehran"
I get the error: unsupported operand type for <: '<class 'datetime.datetime'>' When I try to edit object in Djago admin.
Thanks in advance
trying to pip install https://github.com/slashmili/django-jalali/archive/master.zip
, i get:
...
Installing collected packages: django-jalali
Running setup.py install for django-jalali
File "/home/user/.venvs/py3/lib/python3.4/site-packages/django_jalali/db/models.py", line 80
except ValueError, e:
^
SyntaxError: invalid syntax
File "/home/user/.venvs/py3/lib/python3.4/site-packages/django_jalali/tests/__init__.py", line 64
jdt_model.date_time = datetime.datetime(1390,01,02)
^
SyntaxError: invalid token
Successfully installed django-jalali
Cleaning up...
Dude you removed deprecated SubfieldBase in your new update to support Django 10. but you forgot to change to_python to from_db_value
https://docs.djangoproject.com/en/1.10/releases/1.8/#subfieldbase
It is not an issue. Feature request:
I have an idea to integrate this module with django to integrate Apps seamless with jalali calendar system.
I am not sure but i would like to share my idea with you.
Define flag in setting to choose calendar system. JALALI_CALENDAR_SYSTEM = True
Check if this flag is true:
It is a brainstorming but i`m working on a such solution for django follow DRY principal and hide complexity from developer.
Thanks
I do not know how this works or why it is need set language and local while site is in server side. Also I do not know Django very well either.
I save a form with date in Jalali. It saves the date (convert) in Gregorian in db and that is what I am looking for. But when I want to edit that data again, it shows date in Gregorian in form widget. so if I save it again it will be converted to Gregorian again. Do this two time and you are 1000 year ahead. I fixed this for my little project But you have fix this.
Also I did all in documentation, but in template I will get date in Gregorian. I do not know about local and language stuffs reason but If I use Django-Jalali It means I nead date in Jalali format, no matter what language or locale my server sat at. For this I add a filter to jformat tag but it is very simple:
from jdatetime import date as jdate def tojalali(value, arg=None): d = jdate.fromgregorian(date=value) return str(d.year) + '/' + str(d.month) + '/' + str(d.day)
This works fine for my know but it is very poor for my future projects. So pleas fix this too (I mean improve this and let be there for newbies like me.
create widget for jalali date filed
we are using django 1.6 and we got this error :
No module named settings
Request Method: GET
Request URL: http://localhost:8000/admin
Django Version: 1.6.5
Exception Type: ImportError
Exception Value:
No module named settings
Exception Location: /usr/local/lib/python2.7/dist-packages/django_jalali/admin/widgets.py in , line 7
Python Executable: /usr/bin/python
Python Version: 2.7.3
here is full traceback :
https://gist.github.com/nodet07/1eaf0e19e3c15a6fce09
i think you forget to import ValidationError from django.core.exceptions
i fix it by adding this line to the first of dist-packages/django_jalali-0.9-py2.7.egg/django_jalali/forms/init.py:
from django.core.exceptions import ValidationError
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 :
from django.db import models
from django_jalali.db.models import jDateTimeField, jDateField
import jdatetime
class Book(models.Model):
name = models.CharField(max_length=20)
written_at = jDateField()
collected_at = jDateTimeField(default=jdatetime.datetime.now)
And registering it with default modeladmin :
from django.contrib import admin
from .models import Book
from django_jalali import admin as j_admin
admin.site.register(Book)
when I set default timezone in settings.py
TIME_ZONE = 'Asia/Tehran'
USE_I18N = True
USE_L10N = True
USE_TZ = True
Error details:
Trace back :
Environment:
Request Method: GET
Request URL: http://localhost:8000/admin/book/book/1/change/
Django Version: 1.11.3
Python Version: 3.5.2
Installed Applications:
('django_jalali',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'book')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware')
Template error:
In template /srv/venvs/jalali-test/lib/python3.5/site-packages/django/contrib/admin/templates/admin/includes/fieldset.html, error at line 19
unsupported operand type for <: '<class 'datetime.datetime'>' 9 : {% for field in line %}
10 : <div{% if not line.fields|length_is:'1' %} class="field-box{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}"{% elif field.is_checkbox %} class="checkbox-row"{% endif %}>
11 : {% if not line.fields|length_is:'1' and not field.is_readonly %}{{ field.errors }}{% endif %}
12 : {% if field.is_checkbox %}
13 : {{ field.field }}{{ field.label_tag }}
14 : {% else %}
15 : {{ field.label_tag }}
16 : {% if field.is_readonly %}
17 : <div class="readonly">{{ field.contents }}</div>
18 : {% else %}
19 : {{ field.field }}
20 : {% endif %}
21 : {% endif %}
22 : {% if field.field.help_text %}
23 : <div class="help">{{ field.field.help_text|safe }}</div>
24 : {% endif %}
25 : </div>
26 : {% endfor %}
27 : </div>
28 : {% endfor %}
29 : </fieldset>
Traceback:
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/core/handlers/base.py" in _legacy_get_response
249. response = self._get_response(request)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
217. response = self.process_exception_by_middleware(e, request)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
215. response = response.render()
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/response.py" in render
107. self.content = self.rendered_content
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/response.py" in rendered_content
84. content = template.render(context, self._request)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/backends/django.py" in render
66. return self.template.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
207. return self._render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/loader_tags.py" in render
177. return compiled_parent._render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/loader_tags.py" in render
177. return compiled_parent._render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/loader_tags.py" in render
72. result = block.nodelist.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/loader_tags.py" in render
72. result = block.nodelist.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/defaulttags.py" in render
216. nodelist.append(node.render_annotated(context))
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/loader_tags.py" in render
216. return template.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
209. return self._render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in _render
199. return self.nodelist.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/defaulttags.py" in render
216. nodelist.append(node.render_annotated(context))
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/defaulttags.py" in render
216. nodelist.append(node.render_annotated(context))
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/defaulttags.py" in render
322. return nodelist.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/defaulttags.py" in render
322. return nodelist.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
990. bit = node.render_annotated(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_annotated
957. return self.render(context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render
1046. return render_value_in_context(output, context)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/template/base.py" in render_value_in_context
1024. value = force_text(value)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/utils/encoding.py" in force_text
76. s = six.text_type(s)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/utils/html.py" in <lambda>
385. klass.__str__ = lambda self: mark_safe(klass_str(self))
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/forms/boundfield.py" in __str__
40. return self.as_widget() + self.as_hidden(only_initial=True)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/forms/boundfield.py" in as_widget
127. **kwargs
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/forms/widgets.py" in render
220. context = self.get_context(name, value, attrs)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/forms/widgets.py" in get_context
797. value = self.decompress(value)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/forms/widgets.py" in decompress
876. value = to_current_timezone(value)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/forms/utils.py" in to_current_timezone
192. return timezone.make_naive(value, current_timezone)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/django/utils/timezone.py" in make_naive
307. value = timezone.normalize(value)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/pytz/tzinfo.py" in normalize
242. return self.fromutc(dt)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/pytz/tzinfo.py" in fromutc
185. idx = max(0, bisect_right(self._utc_transition_times, dt) - 1)
File "/srv/venvs/jalali-test/lib/python3.5/site-packages/jdatetime/__init__.py" in __lt__
987. (type(other_datetime)))
Exception Type: TypeError at /admin/book/book/1/change/
Exception Value: unsupported operand type for <: '<class 'datetime.datetime'>'
After tracing the error(in django 1.11) I found out,
django_jalali.admin.widgets.AdminSplitjDateTime
inherits from django.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 to timezone.make_naive
the datetime value(making the datetime, timezone unaware)
so it calls pytz
methods, there it will try to compare jdatetime
with native python's datetime
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 dependency
I'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
No plan for newer django versions?
Hi
when I use django-jalali in my model, in admin panel widgets are OK but in any ModelForm widgets not shown. why?
django 1.10 and python 2.7
If I define my model field like this:
class Book(models.Model):
objects = jmodels.jManager()
jdate = jmodels.jDateTimeField(auto_now_add=True)
when a new Book instance is created with book = Book.objects.create()
, jdate 's value will be my local machine time (my laptop)!
And I need the time be equal the timezone. I need to calculate the elapsed time. But because of the local time, the elapsed time would be a minus number!!
utcnow = jdatetime.datetime.utcnow().replace(tzinfo=utc)
bookDate = book.jdate
elapsedTime = utcnow - bookDate
I also have the USE_TZ = True
in the settings.py
Am I doing something wrong? Or django-jalali does not support timezone aware type?
Thanks in advance
i installed the app , and create the model when i try to makemigrations this error shows to me :
No module named django_jalali
Please provide your configurations and softwares version
First of all thank you so much for your brilliant package. Every thing worked pretty good when I used sqlite and postgres;However, when I decided to use mysql instead, I faced this error at the moment of saving values.
"(1292, "Incorrect datetime value: '2019-03-08 15:16:22+03:30' for column 'Pub_date' at row 1")"
any help would be appreciated in advance ...
Please provide your configurations and softwares version
this is my model:
class UserComment(models.Model):
created=jmodels.jDateField(("Date"), auto_now_add=True)
updated_at=jmodels.jDateField(("Date"), auto_now_add=True)
usercm_id=models.ForeignKey(Person, on_delete=models.CASCADE,default='1',related_name='usercm_id')
storecm_id=models.ForeignKey(Store, on_delete=models.CASCADE,default='1',related_name='storecm_id')
username= models.CharField(max_length=100, default='',null=True)
cm =models.TextField(blank=True, null=True, default='')
def __str__(self):
return str(self.usercm_id)
and this is my serilizer:
class UserCommentSerializer(serializers.ModelSerializer):
class Meta:
model=UserComment
fields=('id','created','cm','usercm_id','storecm_id','username')
and my view is:
class UserCommentViewSet(viewsets.ModelViewSet):
queryset = UserComment.objects.all()
serializer_class = UserCommentSerializer
filter_backends=(filters.DjangoFilterBackend,)
filter_class =CommentFilter
and after post comment my error is:
AttributeError at /usercomments/
'jDateField' object has no attribute '_get_val_from_obj'
how to fix it?
hi, i set django_jalali for app.
datepicker work correct but date field show gregorian date.
on linux work correct but on windows didn't work correct.
and on linux without set locale work correct.
for fix this issue i set locale on two os but get this error unsupported locale setting
in two os.
Hi dudes,
I created this field in my model
createTimeJalali = jmodels.jDateTimeField(auto_now=True)
and I want to get a query based on year in my view
news_list = News.objects.filter(createTimeJalali__year=y).order_by('-id')
but I get this error when I run the project
Unsupported lookup 'year' for jDateTimeField or join on the field not permitted.
what's the problem here?
hi.
there is a problem to showing calendar icon in add or edit forms in django admin.
with inspect element i see that :
<img id="id_createdate_calendar" src="/missing-admin-media-prefix/img/icon_calendar.gif" alt="Calendar">
i use from latest version of django and python .
regards.
I have a model named Semester and a form like this:
class Semester(models.Model):
title = models.CharField(max_length=128, verbose_name=_('title'), unique=True)
start_date = jmodels.jDateField(verbose_name=_('start date'))
end_date = jmodels.jDateField(verbose_name=_('end date'))
def __str__(self):
return self.title
class Meta:
verbose_name = _("semester")
verbose_name_plural = _("semesters")
ordering = ('-start_date',)
class SemesterForm(forms.ModelForm):
class Meta:
model = Semester
fields = ['title', 'start_date', 'end_date']
in the admin page, I encounter a Enter a valid date_ error message when I choose to set 13xx-06-31 as either start date or end date.
I use django-jalali 2.4.4 and jdatetime 1.9.0 with django 1.10.5.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.