python 3.7.3 django 版本 2.2.1
我刚刚开始学习 Django 并完成了他们的投票教程。
我正在尝试安装 django CMS 包 https://github.com/nephila/djangocms-blog
运行 python3 manage.py migrate 后出现以下错误:
类型错误:__init__() 缺少 1 个必需的位置参数:'on_delete'
我已阅读 Getting TypeError: __init__() missing 1 required positional argument: 'on_delete' when trying to add parent table after child table with entries 上建议的解决方案但它没有解决
如何解决?
以下是我的models.py
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
def __str__(self):
return self.choice_text
设置.py
INSTALLED_APPS = [
'django.contrib.sites',
'polls.apps.PollsConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# CMS Blog
'cms',
'menus',
'filer',
'easy_thumbnails',
'aldryn_apphooks_config',
'cmsplugin_filer_image',
'parler',
'taggit',
'taggit_autosuggest',
'meta',
'sortedm2m',
'djangocms_blog',
]
请您参考如下方法:
我找到了解决方案。
CMS 插件文件管理器已被弃用: https://github.com/divio/cmsplugin-filer
遗留在Django CMS Blog的安装说明中,但应该删除。解释在这里 https://github.com/nephila/djangocms-blog/issues/431
这个插件的功能已经被Filer ThumbnailOption替代,所以你可以去掉这个位
'cmsplugin_filer_image'
来自 django settings.py> INSTALLED_APPS
它应该可以工作了。
编辑:您还需要安装最新版本的 djangocms-blog
pip install djangocms-blog==1.0.0rc1
