0

これが私のモデルです:

class BaseModelTalk(models.Model):

    name            = models.CharField('Name', max_length = 100)
    slug            = models.SlugField('Slug', blank = True)
    creator         = models.ForeignKey('person.Person')
    date_created    = models.DateTimeField(default = now)
    objects         = CustomTalkManager()

    class Meta:
        abstract = True

    def save(self, *args, **kwargs):
        if not self.id:
            self.slug = slugify(self.name)
        super(BaseModelTalk, self).save(*args, **kwargs)

    def __unicode__(self):
        return u'%s' % self.slug

class Talk(BaseModelTalk):

    tags            = TaggableManager()
    description     = models.TextField('Talk description')

    class Meta:
        verbose_name = 'Talk'
        verbose_name_plural = 'Talks'

class ThreadTextRating(RatedItemBase):
    content_object = models.ForeignKey('talk.ThreadText')

class ThreadImageRating(RatedItemBase):
    content_object = models.ForeignKey('talk.ThreadImage')

class ThreadLinkRating(RatedItemBase):
    content_object = models.ForeignKey('talk.ThreadLink')

class Thread(BaseModelTalk):

    THREAD_TYPE = (('text', 'Text'),
                   ('image', 'Image'),
                   ('link', 'Link'))

    type            = models.CharField('Thread\'s type', max_length = 5, choices = THREAD_TYPE, blank = True, null = True)

    class Meta:
        abstract = True

class ThreadText(Thread):

    ratings         = Ratings(ThreadTextRating)
    talk            = models.ForeignKey('talk.Talk', related_name = 'text_threads')
    content         = models.TextField('Thread\'s context')

    class Meta:
        verbose_name = 'Text'
        verbose_name_plural = 'Text\'s'  

class ThreadImage(Thread):

    ratings         = Ratings(ThreadImageRating)
    talk            = models.ForeignKey('talk.Talk', related_name = 'image_threads')
    image           = ImageField('Thread\'s image', upload_to = 'thread/image/')

    class Meta:
        verbose_name = 'Image'
        verbose_name_plural = 'Image\'s'

class ThreadLink(Thread):

    ratings         = Ratings(ThreadLinkRating)
    talk            = models.ForeignKey('talk.Talk', related_name = 'link_threads')
    link            = models.URLField('Thread\'s link')

    class Meta:
        verbose_name = 'Link'
        verbose_name_plural = 'Link\'s'

実行するたびsyncdbに、エラーが発生しました: django.db.utils.DatabaseError: no such table: talk_basemodeltalk.

私はすでにアプリを私のものに入れてsettings.pytalkます。

これの原因は本当にわかりません。唯一の手がかりは、その行にコメントclass MetaBaseModelTalkてもエラーが発生しないことです。

4

1 に答える 1

1

エラーの理由 : カスタムまたは非カスタムのマネージャーを明示的に定義するモデルをサブクラス化することはできません。objectsラインを削除しBaseModelTalkて各モデルに配置するだけで、abstract = False修正されます。

于 2012-12-18T09:50:41.900 に答える