Closed Mehran-Isapour closed 4 years ago
Hi @Mehran-Isapour. Thanks for reporting. I will check it in my free time. It may take some time.
Thank you so much! So I'll wait because I have used it in my project and I am going to finish it. Should I have done anything other than what I wrote above? Thanks again!
forms.widgets.jDateTimeInput
is a form widget not a date picker
.
If you want to have admin date picker in your form you have to use admin.widgets.AdminSplitjDateTime for DateTimeField and admin.widgets.AdminjDateWidget for DateField.
To enable it for your model form first import it:
from django_jalali.admin import widgets
and use it like:
widgets = {'datetime': widgets.AdminSplitjDateTime}
Then, you need to include admin related js files in your template by:
<script type="text/javascript" src="/admin/jsi18n/"></script>
<script type="text/javascript" src="/static/admin/js/core.js"></script>
{{ form.media }}
{{ form }}
Thanks a lot for your attention. I want to take a date from the user using a date picker and save it in a model instance. (On the normal page that the user sees, not on the site admin page) Is the instruction you wrote what I need to do? or do I need to install a plugin to do it?
Is the instruction you wrote what I need to do?
Yes, If you want to have Django jalali admin data picker on your form.
I would suggest using another data picker plugin because this is for the admin page
Thank you very much for your guidance.
I'm closing this issue. Feel free to open it again if you have further questions.
forms.widgets.jDateTimeInput
is a form widget not adate picker
. If you want to have admin date picker in your form you have to use admin.widgets.AdminSplitjDateTime for DateTimeField and admin.widgets.AdminjDateWidget for DateField. To enable it for your model form first import it:from django_jalali.admin import widgets
and use it like:
widgets = {'datetime': widgets.AdminSplitjDateTime}
Then, you need to include admin related js files in your template by:
<script type="text/javascript" src="/admin/jsi18n/"></script> <script type="text/javascript" src="/static/admin/js/core.js"></script> {{ form.media }} {{ form }}
hi , sorry i missed up i imported widgets and used inside my ModelAdmin but where should i include these javascript lines ?
{{ form.media }} {{ form }}
thanks for your help
Hi,
but where should i include these javascript lines ?
in your template file.
Please provide your configurations and softwares version
Hi. How do I add the jalali date picker to my template?
More details: I used jDatetime field in my model. Then I created a form based on it with ModelForm. I also added the following code to the form: widgets = { 'my_date': widgets.jDateTimeInput } But when the form is rendered on the template, jDateTimeField displaying a textbox instead of a date picker Would you please tell me what to do? Thank you!