'showing date from db in html date in django
How can i show date from db in django html template with input type date.
As You can see if we use input type 'date'. we can see the below widget showing in html. But if i want to it to show date from DB in below picture. Is there anyway i can do?

Showing like this, so user can see the current date from DB and change if needed.

forms.py
class ProfileUpdateForm(ModelForm):
#birthdate = forms.DateField(
# input_formats=['%dd-%mm-%yyyy'],
# widget=forms.DateInput(format='%dd-%mm-%yyyy', attrs={'type': "date"})
# )
class Meta:
model = User
fields = [
'email',
'full_name',
'address',
'city',
'state',
'postcode',
'phone_number',
'birthdate',
]
widgets = {
'full_name': Textarea(attrs={'cols': 35, 'rows': 1}),
'address': Textarea(attrs={'cols': 80, 'rows': 3}),
'city': Textarea(attrs={'cols': 35, 'rows': 1}),
'birthdate': forms.DateInput(format='%d %b %Y', attrs={'type':'date'}),
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
