Friday, June 7, 2019

Re: DateInput not accepting format argument

Try this:

in settings.py
USE_L10N = False

USE_TZ = True

DATE_INPUT_FORMATS = ['%B %d, %Y']

In forms.py
start_date = forms.DateField(
widget=forms.DateInput(attrs={'placeholder': 'October 24, 2019'}),
)

On Friday, June 7, 2019 at 5:36:30 AM UTC-5, Dube Software wrote:
Hi,

I have a form with a start_date field of type DateField (widget is DateInput).

When I specify a format argument, the input does not render as specified. The format is always YYYY-MM-DD. My code is as follows:

```
start_date = forms.DateField(
label='Start date',
widget=forms.widgets.DateInput(
format='%d %B, %Y',
attrs = {
'type': 'date',
}
)
)
```
What am I missing?

Kind regards,
Lloyd

Sent with Shift

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/eda17f1f-ec6b-45c9-a7d8-5f0af0b125b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment