2014-03-24 38 views
0

我的一個模型出現奇怪的問題。我有一個Podcast型號,它繼承自BCCFChildPage的基本型號RatingFieldCommentsField未知列`comments_count`

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'") 

回答

0

您使用的夾層?我對django很陌生,但如果你閱讀夾層的文檔,他們建議你只從頁面(另外還有Richtext)和BlogPost類繼承。在添加翻譯功能和新的自定義帖子類型時,我發現自己遇到了同樣的問題兩次。如果你的對象不適合任何這兩個類的,你可以從這些模型繼承並注入任何你想要的改變:http://mezzanine.jupo.org/docs/model-customization.html

我認爲這是夾層的方式..