加一个时间字段,修改表 models.py
class info(models.Model):
name = models.CharField(max_length=16)
age = models.IntegerField(default=100)
date = models.DateTimeField()
写入到数据库
python manage.py makemigrations
python manage.py migrate
时间操作
# 新增
# import datetime
# now = datetime.datetime.now()
# models.info.objects.create(name='wangwu',age=10086,date=now)
# 查询
# obj = models.info.objects.filter(date__year=2000,date__month=12,date__day=1)
# print(obj.values())