小编leg*_*end的帖子

Django makemigrations AttributeError:'str'对象没有属性'_meta'

我正在使用django框架,我遇到了运行makemigration命令的问题.这是模型的副本及其生成的堆栈跟踪.我看过几个帖子有同样的错误,但没有一个让我在这里解决我的问题.我正在使用django 1.9.4

from django.db import models
import os, uuid

# Create your models here.
def video_directory_path(instance, folder):
    return os.path.join('video', str(instance.person.id), str(instance.video_id))

def photo_directory_path(instance, folder):
        return os.path.join('image', str(instance.person.id), str(instance.photo_id))


class Image(models.Model):
    name = models.CharField(max_length=128)
    photo_id = models.UUIDField(verbose_name='photo id', default=uuid.uuid4, editable=False, unique=True)
    photo = models.ImageField(upload_to=photo_directory_path)
    person = models.ForeignKey('Person', on_delete=models.CASCADE)
    movie = models.ForeignKey('Movie', on_delete=models.CASCADE)

    class Meta:
        db_table = 'Image'

    def __str__(self):
        return '[{0}- {1}]'.format(self.__class__.__name__, self.id)

    def __repr__(self):
        return self.__str__()


class Video(models.Model):
    name = models.CharField(max_length=128)
    video_id = models.UUIDField(verbose_name='video id', default=uuid.uuid4, editable=False, unique=True) …
Run Code Online (Sandbox Code Playgroud)

django django-models django-database

6
推荐指数
1
解决办法
8608
查看次数

标签 统计

django ×1

django-database ×1

django-models ×1