我是Django的初学者,我正在尝试制作传记应用程序,我在学习Django的官方文档。因此,当我在docs中显示的在models.py中创建DateField时,在运行服务器时出现错误,提示“函数缺少必需的参数'month'(位置2)” 我该怎么办?请帮忙
#models.py
from django.db import models
from django.utils import timezone
import datetime
# Create your models here.
TYPE = (
('politician','POLITICIAN'),
('poet','POET'),
('author','AUTHOR'),
('actor','ACTOR'),
)
class About(models.Model):
title = models.CharField(max_length = 200, default='')
context = models.CharField(max_length = 200, default='')
born_on = models.DateField('Born on')
died_on = models.DateField( 'Died on')
main = models.TextField(default='')
category = models.CharField(choices = TYPE , default = 'poet', max_length = 10)
image = models.ImageField(blank=True, default='', upload_to='static')
updated_on = models.DateTimeField(auto_now = True)
created_on = models.DateTimeField(auto_now_add = True)
def __str__(self):
return self.title
def was_published_recently(self):
return self.created_on >= timezone.now() - datetime.timedelta(days=1)