Django迁移错误:TypeError:int()参数必须是字符串,类似字节的对象或数字,而不是'datetime.datetime'

时间:2019-11-14 14:06:12

标签: python django django-models

我尝试为我的字段设置默认值,但是会导致错误。

文件:

Models.py

        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'

0 个答案:

没有答案