0
我的模型有一个DateField
:Django:格式化模型继承的DateField
class Info(models.Model):
userprofile = models.OneToOneField(UserProfile, primary_key=True)
birth_date = models.DateField()
我从它生成一个表格:
class SecondStepForm(ModelForm):
class Meta:
model = Info
exclude = ('userprofile',)
问题是我要格式化日期输入。我知道有可能使用forms.DateField
:
birth_date = forms.DateField(widget=forms.DateInput(format = '%d/%m/%Y'), input_formats=('%d/%m/%Y',))
但是如何告诉django应该从模型中创建一个表单,除了应该使用forms.DateField
的日期字段?