Monday, June 10, 2019

Re: DateInput not accepting format argument

Thanks @Joe. I had been trying to avoid using a third party app if I could help it. I ended up using the default Django DateTime widget as-is. Will try out your recommendation if the need arises.

Kind regards,
Lloyd


Sent with Shift

On Fri, Jun 7, 2019 at 10:11 PM Joe Reitman <jreitman28@gmail.com> wrote:
Or a better option is to use a third party app such as https://django-bootstrap-datepicker-plus.readthedocs.io/en/latest/index.html

On Friday, June 7, 2019 at 1:05:04 PM UTC-5, Joe Reitman wrote:
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/28af33d7-359a-499e-9576-2729fc742ce8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAH-SnCD4_QB%3DkRPnSYL1MhTuVZnE8GQU208-7vgjOUgOxdvREQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment