未知列`comments\u count`

2024-10-03 23:27:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我的一个模特有个奇怪的问题。我有一个模型Podcast,它继承自具有RatingFieldCommentsField的基本模型BCCFChildPage。你知道吗

Podcast之外,其他所有子模型都有效。奇怪的是,这只发生在我的一个模特身上,而不是其他所有模特身上。你知道吗

任何输入或意见将是伟大的。你知道吗

谢谢。你知道吗

型号:

基本型号:

class BCCFChildPage(BCCFBasePage, RichText, AdminThumbMixin):
    """
    This is the page that shows up in the fancy carousels.
    """
    TYPES = (
        ('parent', 'Parents'),
        ('professional', 'Professionals'),
    )

    parent = models.ForeignKey('BCCFChildPage', blank=True, null=True)
    gparent = models.ForeignKey('BCCFPage', verbose_name="Parent Page", blank=True, null=True)
    bccf_topic = models.ManyToManyField('BCCFTopic', blank=True, null=True)
    featured = models.BooleanField('Featured', default=False)
    titles = models.CharField(editable=False, max_length=1000, null=True)
    content_model = models.CharField(editable=False, max_length=50, null=True, blank=True)
    rating = RatingField(verbose_name='Rating')
    comments = CommentsField()
    page_for = models.CharField('Type', max_length=13, default='parent', blank=True, null=True, choices=TYPES)
    image = FileField("Image",
        upload_to = upload_to("bccf.ChildPage.image_file", "childpage"),
        extensions = ['.png', '.jpg', '.bmp', '.gif'],
        max_length = 255,
        null = True,
        blank = True,
        help_text = 'You can upload an image. '
            'Acceptable file types: .png, .jpg, .bmp, .gif.')

    objects = managers.ChildPageManager()

    class Meta:
        verbose_name = 'BCCF Child Page'
        verbose_name_plural = 'BCCF Child Pages'
        ordering = ("-created",)

    # Functions below...

儿童模特(播客):

class Podcast(BCCFChildPage):
    attached_audio = FileField('Audio File',
       upload_to = upload_to("bccf.Podcast.attachment_audio", "resource/audio"),
        extensions = ['.mp3'],
        max_length = 1024,
        null = True,
        blank = True,
        help_text = 'You can upload an MP3. Acceptable file types: mp3')
    product = models.ForeignKey(Product, verbose_name='Associated Product', blank=True, null=True)

    class Meta:
        verbose_name = 'Podcast'
        verbose_name_plural = 'Podcasts'

错误

(1054, "Unknown column 'bccf_podcast.comments_count' in 'field list'")

回溯

Environment:


Request Method: GET
Request URL: http://bccf-staging.bjola.ca/admin/bccf/podcast/

Django Version: 1.6.2
Python Version: 2.7.3
Installed Applications:
('mezzanine.boot',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.redirects',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.sitemaps',
 'django.contrib.staticfiles',
 'ckeditor',
 'mezzanine.conf',
 'mezzanine.core',
 'mezzanine.generic',
 'mezzanine.forms',
 'mezzanine.pages',
 'mezzanine.twitter',
 'mezzanine.accounts',
 'news',
 'pybb',
 'bccf',
 'cartridge.shop',
 'formable.builder',
 'form_utils',
 'embed_video',
 'filebrowser_safe',
 'south',
 'grappelli_safe',
 'django.contrib.admin',
 'django.contrib.comments')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'cartridge.shop.middleware.ShopMiddleware',
 'mezzanine.core.request.CurrentRequestMiddleware',
 'mezzanine.core.middleware.RedirectFallbackMiddleware',
 'mezzanine.core.middleware.TemplateForDeviceMiddleware',
 'mezzanine.core.middleware.TemplateForHostMiddleware',
 'mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware',
 'mezzanine.core.middleware.SitePermissionMiddleware',
 'mezzanine.pages.middleware.PageMiddleware',
 'pybb.middleware.PybbMiddleware')


Traceback:
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  432.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  99.                     response = view_func(request, *args, **kwargs)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  198.             return view(request, *args, **kwargs)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  29.             return bound_func(*args, **kwargs)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  99.                     response = view_func(request, *args, **kwargs)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  25.                 return func(self, *args2, **kwargs2)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/contrib/admin/options.py" in changelist_view
  1395.             media = self.media + formset.media
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/forms/formsets.py" in media
  373.         if self.forms:
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/utils/functional.py" in __get__
  49.         res = instance.__dict__[self.func.__name__] = self.func(instance)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/forms/formsets.py" in forms
  133.         forms = [self._construct_form(i) for i in xrange(self.total_form_count())]
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/forms/formsets.py" in total_form_count
  108.             initial_forms = self.initial_form_count()
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/forms/models.py" in initial_form_count
  550.             return len(self.get_queryset())
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/db/models/query.py" in __len__
  77.         self._fetch_all()
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
  854.             self._result_cache = list(self.iterator())
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/db/models/query.py" in iterator
  220.         for row in compiler.results_iter():
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
  709.         for rows in self.execute_sql(MULTI):
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  782.         cursor.execute(sql, params)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/db/backends/util.py" in execute
  69.             return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/db/backends/util.py" in execute
  53.                 return self.cursor.execute(sql, params)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/db/utils.py" in __exit__
  99.                 six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/db/backends/util.py" in execute
  53.                 return self.cursor.execute(sql, params)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/django/db/backends/mysql/base.py" in execute
  124.             return self.cursor.execute(query, args)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/MySQLdb/cursors.py" in execute
  201.             self.errorhandler(self, exc, value)
File "/home/vcn/webapps/bccf/lib/python2.7/site-packages/MySQLdb/connections.py" in defaulterrorhandler
  36.     raise errorclass, errorvalue

Exception Type: OperationalError at /admin/bccf/podcast/
Exception Value: (1054, "Unknown column 'bccf_podcast.comments_count' in 'field list'")

Tags: djangoinpyselftruehomelibpackages
1条回答
网友
1楼 · 发布于 2024-10-03 23:27:18

你在用夹层吗?我对django非常陌生,但是如果你阅读了mezzanine的文档,他们会建议你只继承他们的页面(另外还有Richtext)和BlogPost类。在添加翻译功能和新的自定义帖子类型时,我两次发现自己遇到了同样的问题。如果您的对象不适合这两个类中的任何一个,您可以从这些模型继承并注入您想要的任何更改:http://mezzanine.jupo.org/docs/model-customization.html

我想那是夹层的方式。。你知道吗

相关问题 更多 >