-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Displays Gregorian date #249
Comments
I figured out what is the issue. If I define the field like this:
Then this is what I have in the admin site (i.e the datepicker works correctly) However if I change the field to this:
Then the datepicker does not work: So, is that intentional? What is the solution here? |
have you tested |
Yes it works however the field disappears from the admin site because I need to set the field's value automatically, but edit it later if I need to. That's why |
What if you use publish = jmodels.jDateTimeField(default=jdatetime.datetime.now) if you want to get the timezone based on the setting,s you need to write a function like def current_datetime():
dt = jdatetime.datetime.now()
new_dt = .. do something with dt to get the timezone from settings and apply it on the datetime
new_dt
class Post(models.Model):
publish = jmodels.jDateTimeField(default=current_datetime)
if you figure out how is it done, a PR is welcomed to add it as |
how about
|
Looks good! |
Configurations
Here's my setup:
models.py:
With the above setup, the add form in the admin site still displays the Gregorian date:
And the datepicker is showing the wrong date (it shows Shahrivar because now it is month 6 of Gregorian calendar):
Ironically, in the same project, in my custom user model I have this:
models.py
And this is how it looks in the Admin site:
So it works without any issue.
The only difference between those two models is that one of them is my own, and the other one is a subclass of Django's User model.
The text was updated successfully, but these errors were encountered: