我的一个模特遇到了一个奇怪的问题。我有一个模型Podcast
,它继承自BCCFChildPage
和RatingField
的基础模型CommentsField
。
除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 :(得分:0)
我认为这是夹层方式..