Daniel
Daniel

Reputation: 1575

Django: DateField in Form must have different format

I have a DateField() object named event_date, and a view that renders an <input type="text" /> widget.

My problem is that the DateField() object stores the date in the form yyyy-mm-dd, but the <input> field must accept the input in the form dd.mm.yyyy. This does not validate. Is there any way I can do this?

Upvotes: 0

Views: 214

Answers (1)

bx2
bx2

Reputation: 6476

Did you try to localize your inputs? https://docs.djangoproject.com/en/dev/topics/i18n/formatting/#locale-aware-input-in-forms

Other way would be to use a custom field in the form.

Upvotes: 1

Related Questions