我正在尝试在admin中使用input_foramts但它没有任何效果。 我做错了什么?
#model
class Feedback(models.Model):
created_at = models.DateTimeField(auto_now_add = True)
#admin form class FeedbackAdminForm(forms.ModelForm): created_at = forms.DateTimeField(input_formats =('%d /%m /%Y',)) 类Meta: model =反馈
#admin class FeedbackAdmin(admin.ModelAdmin): form = FeedbackAdminForm admin.site.register(反馈,FeedbackAdmin)
由于
答案 0 :(得分:2)
也许您可以像这样使用ModelAdmin.formfield_overrides:
class Feedback(models.Model):
created_at = models.DateTimeField()
class Meta:
verbose_name = 'Feedback'
verbose_name_plural = 'Feedbacks'
def __unicode__(self):
return u'%s' % (self.created_at)
class FeedbackAdmin(admin.ModelAdmin):
formfield_overrides = {
models.DateTimeField: {'input_formats': ('%d/%m/%Y',)},
}