Python Django migrate error:TypeError:int()参数必须是字符串、类似字节的对象或数字,而不是';datetime.datetime';
我试图为我的字段设置默认值,但这会导致错误 档案: 型号.pyPython Django migrate error:TypeError:int()参数必须是字符串、类似字节的对象或数字,而不是';datetime.datetime';,python,django,django-models,Python,Django,Django Models,我试图为我的字段设置默认值,但这会导致错误 档案: 型号.py from django.db import models from django.contrib.auth.models import User # Create your models here. STATUS = [ (0, "Draft"), (1, "Publish") ] cl
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
STATUS = [
(0, "Draft"),
(1, "Publish")
]
class Posts(models.Model):
title = models.CharField(max_length=200, unique=True)
slug = models.SlugField(max_length=200, unique=True)
author = models.ForeignKey(User, on_delete= models.CASCADE,related_name='blog_posts')
content = models.TextField()
created_on = models.DateTimeField(db_index=True,auto_now=True)
status = models.IntegerField(choices=STATUS, default=0)
我得到以下错误:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'datetime.datetime'
您可以共享迁移吗?请尝试更改括号中的
状态
是否尝试删除迁移并重新创建?也许你把事情搞砸了。