How to change Django date format to dd/ mm/ yy?
问题 In forms.py: class DobForm(forms.ModelForm) dob = forms.DateField(widget=forms.TextInput(attrs={'class':'datepicker'}),required=True,input_formats=['%d/%m/%Y',]) class Meta: model = Dob In my html: $(function() {$(".datepicker").datepicker({ maxDate: '0',dateFormat: 'dd-mm-yy' })});</script> Its thorwing error in the form: Enter a valid date 回答1: You need to make the formats the same for both django and jquery. Try this for the DateField (django): ...,input_formats=['%d-%m-%Y',]) and in the