Hi,

The history of why is here:
https://code.djangoproject.com/ticket/16630#comment:11

You can get type="date" like so on your form: birth_date
= forms.DateField(attrs={'type': 'date'}, required=False)

Thanks,
Collin


On Tue, Jan 23, 2018 at 12:43 AM, Ruchit Bhatt <ruchitinnewfush...@gmail.com
> wrote:

> Hi folks,
> Here i am eager to find out why django render model dateField type as text
> ??
>
> <input type="text" ...>
>
> instead of
> <input type="date" ...>
>
> *Is there any alternative or inbuilt method to render datefield as date ?*
>
>
> This is my code
>
> *models.py*
>     class HumanUser(AbstractUser):
>         birth_date = models.DateField(null=True, blank=True, verbose_name=
> u"DOB")
>
>
> *forms.py*
> class profile_form(forms.ModelForm):
>
>     def __init__(self, *args, **kwargs):
>         kwargs.setdefault('label_suffix', '')
>         super(profile_form, self).__init__(*args, **kwargs)
>         for field in self.fields:
>             self.fields[field].widget.attrs.update({'class': 'form-control
> form-control-line', })
>
>     class Meta:
>         model = User
>         fields = [
>             'full_name',
>             'birth_date',
>             'mobile',
>             'bio',
>             'gender',
>         ]
>
>
> *HTML output*
>
> <input type="text" name="birth_date" class="form-control form-control-line" 
> id="id_birth_date" />
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/caa35f1c-3a8e-4e45-954b-
> 14876efdf8db%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/caa35f1c-3a8e-4e45-954b-14876efdf8db%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAFO84S7iFbgnV7FqE56xvM_EuY5sYA9jXAgErxmkie8ijgxbFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to