Monday, January 22, 2018

modelform DateField rendering as text

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',
       
]


This is my code where birth_date type is showing as text instead of date in HTML..any idea why ?

<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 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/a8d31158-393f-4a03-8805-116508234d35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment