У меня есть следующее:
Модель:
class customer(models.Model):
cstid = models.AutoField(primary_key=True, unique=True)
name = models.CharField(max_length=35)
ageyrs=models.IntegerField(blank=True)
agemnths=models.IntegerField(blank=True)
dob = models.DateField(null=True, blank=True)
gender_choices = (('male', 'Male'),
('female', 'Female'),
('other', 'Something else'),
('decline', 'Decline to answer'))
gender = models.CharField(
choices=gender_choices, max_length=10, default='male')
maritalstatus_choices = (('unmarried', 'Unmarried'),
('married', 'Married'))
maritalstatus = models.CharField(
choices=maritalstatus_choices, max_length=10, default='Unmarried')
mobile = models.CharField(max_length=15, default='')
alternate = models.CharField(max_length=15, default='', blank=True)
email = models.CharField(max_length=50, default='', blank=True)
address = models.CharField(max_length=80, default='', blank=True)
city = models.CharField(max_length=25, default='', blank=True)
occupation = models.CharField(max_length=25, default='', blank=True)
bloodgroup_choices = (('apos', 'A+'),
('aneg', 'A-'),
('bpos', 'B+'),
('bneg', 'B-'),
('opos', 'O+'),
('oneg', 'O-'),
('abpos', 'AB+'),
('abneg', 'AB-')
)
bloodgroup = models.CharField(choices=bloodgroup_choices, max_length=5, default='-', blank=True)
class Meta:
unique_together = ["name", "mobile", "linkedclinic"]
My ModelForm:
class RegisterPatientMetaForm(ModelForm):
class Meta:
dob = forms.DateField(input_formats=['%d-%m-%Y'])
model = customer
fields = [
'name',
'ageyrs',
'agemnths',
'dob',
'gender',
'maritalstatus',
'mobile',
'alternate',
'email',
'address',
'city',
'occupation',
'bloodgroup'
]
В моем шаблоне у меня есть:
<div class="col-md-8">
<label for="gender">Date of Birth</label>
{{ form.dob }}
</div>
Проблема в том, что дата отображается как% Y-% m-% d, а я хочу, чтобы она отображалась как% d-% m-% Y. Что не так с тем, как я это делаю? Как я могу это исправить?