我正在尝试运行迁移,但是当我运行migration.py时遇到类型错误?

时间:2019-02-26 09:36:19

标签: django django-models django-migrations

我遇到了一个大错误,但主要问题是:

  

要执行的操作:应用所有迁移:管理员,应用,身份验证,   内容类型,会话,订阅正在运行的迁移:正在应用   app.0019_auto_20190224_0449 ...回溯(最近通话最近):
  文件“ C:\ Users \ Ubaid   Parveez \ AppData \ Local \ Programs \ Python \ Python36 \ lib \ site-packages \ django \ utils \ dateparse.py“,   第106行,位于parse_datetime中       match = datetime_re.match(value)TypeError: expected string or bytes-like object

这里是models.py

from django.db import models
from django.contrib.auth.models import User
from django.urls import reverse
from tinymce import HTMLField



class Category(models.Model):
    title = models.CharField(max_length = 20)

    def __str__(self):
        return self.title

class Post(models.Model):
    image = models.ImageField()
    title = models.CharField(max_length = 100)
    body = HTMLField()
    published_date = models.DateTimeField(auto_now_add = True)
    categories = models.ManyToManyField(Category)
    featured = models.BooleanField(default = False)


    def __str__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('blog',kwargs = {
            'pk':self.pk
            })

    @property
    def get_comments(self):
        return self.comments.all()




class Comment(models.Model):
    post = models.ForeignKey(Post,on_delete=models.CASCADE,related_name = "comments")
    name = models.CharField(max_length = 200)
    body = models.TextField()

    def __str__(self):
       return self.name



class Upload(models.Model):
    image = models.ImageField(upload_to = 'images')
    content = models.FileField(upload_to = 'images/%Y/%M/%d')

0 个答案:

没有答案