Closed xSerioUsx78 closed 2 years ago
Hi, Please provide your model and admin code. it would be great to provide a picture of the rendered widget. Then I will take a look and let you know! Thanks!
First of all, Thank you for the fast response. I summarized the code so that you would not be bothered when checking. my django version: 4.0.2
models.py
from django_jalali.db import models as jmodels
class PostManager(jmodels.jManager):
...
class Post(models.Model):
...
timestamp = jmodels.jDateTimeField(
default=timezone.now, verbose_name=_('تاریخ و زمان انتشار'))
STATUS = Choices(('D', 'پیش نویس'), ('P', 'منتشر شده'))
status = StatusField(choices_name='STATUS', default='D',
verbose_name=_('وضعیت انتشار'))
objects = PostManager()
admin.py
from django.contrib import admin
from django.utils.html import format_html
from hitcount.models import HitCount
from .models import Post
import django_jalali.admin as jadmin
# Register your models here.
@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
...
Thanks for providing more info. I will check it later and will let you know!
Thank you!
@xSerioUsx78 just a side note: please drop the screenshots into the comment textbox GitHub allows us to share/upload the images safely inside GitHub platform.
@xSerioUsx78 I've created a fresh project and the widget works well for me
Which version of Django and djnago-jalali are you using?
@slashmili Sorry for that, i will share via github next time thank you.
@hramezani Django 4.0.2, django-jalali 5.1.0
I found out where the problem came from.
the problem was from default=timezone.now
timestamp = jmodels.jDateTimeField(
default=timezone.now, verbose_name=_('تاریخ و زمان انتشار'))
I changed it to default=jdatetime.datetime.now
timestamp = jmodels.jDateTimeField(
default=jdatetime.datetime.now, verbose_name=_('تاریخ و زمان انتشار'))
and its work perfectly now. thank you for the great project, keep it up.
Perfect! Thanks for letting us know! I close this issue.
Now the widget works but when i tried to add a post, django give me an error and it's weird, when i made the jdatetime field auto_now_add=True it works, but when i tried to add datetime manually it give me this error
1400-11-19 18:41:59در محدوده زمانی Asia/Tehran، قابل تفسیر نیست؛ ممکن است نامشخص باشد یا اصلاً وجود نداشته باشد.
Then i changed the timezone to utc in settings.py but steel i got this error.
1400-11-19 18:41:59در محدوده زمانی utc، قابل تفسیر نیست؛ ممکن است نامشخص باشد یا اصلاً وجود نداشته باشد.
I would suggest creating a new issue for this issue because this one is closed. please also mention more information about the Django and Django-jalali versions and your settings.
Hi, i added the widget in admin.py and the styling works good, but the date is not jalali! is this the default or i can fix it ?