Currently jDateField(input_formats=['%Y/%m/%d']) (or similar usage) would cause validation error for data with correct format. The same issue applies to jDateTimeField.
Looking at the code, the parameter input_formats does not do anything as the logic is not implemented.
This PR provides a solution for using input_formats.
from django import forms
from django_jalali.forms import jDateField, jDateTimeField
class TestForm(forms.Form):
date = jDateField(input_formats=["%Y/%m/%d"])
date_time = jDateTimeField(input_formats=["%Y/%m/%d %H:%M"])
class Meta:
fields = ('date', 'date_time')
>>> form = TestForm(data={'date':'1403/05/28', 'date_time': '1403/05/28 10:10'})
>>> form.is_valid()
False
>>> form.errors
{'date': ['Enter a valid date.'], 'date_time': ['Enter a valid date/time.']}
Problem
Currently
jDateField(input_formats=['%Y/%m/%d'])
(or similar usage) would cause validation error for data with correct format. The same issue applies tojDateTimeField
. Looking at the code, the parameterinput_formats
does not do anything as the logic is not implemented. This PR provides a solution for usinginput_formats
.Related issues
Possibly resolves issues: issue #93 and issue #95
Steps to reproduce the problem
With Fix applied