django-CMS 和 cookiecutter-django 不兼容吗?
Are django-CMS and cookiecutter-django incompatible?
我刚刚尝试将我的 Django-CMS 项目移植到 Django Cookiecutter (cookiecutter-django) 中,以便在 Docker 中将其添加到 运行。
似乎 Django-CMS 使用的是默认的 Django 用户模型,而 Cookie-Cutter 使用的是自定义模型(来自 allauth?)。
我发现了这个 https://github.com/pydanny/cookiecutter-django/pull/248 帖子,它建议更改应用程序的加载顺序,但这并没有削减芥末。
Django-CMS 和 Cookiecutter 相互矛盾吗?
添加: 运行 Django 2.2.7 和 django-cms 3.7.2
编辑: 错误 message/traceback 当我 运行
$ docker-compose -f local.yml up
...
postgres_1 | 2020-04-22 13:58:12.315 UTC [1] LOG: database system is ready to accept connections
django_1 | PostgreSQL is available
django_1 | Traceback (most recent call last):
django_1 | File "manage.py", line 30, in <module>
django_1 | execute_from_command_line(sys.argv)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
django_1 | utility.execute()
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
django_1 | django.setup()
django_1 | File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
django_1 | apps.populate(settings.INSTALLED_APPS)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
django_1 | app_config.import_models()
django_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
django_1 | self.models_module = import_module(models_module_name)
django_1 | File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
django_1 | return _bootstrap._gcd_import(name[level:], package, level)
django_1 | File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
django_1 | File "<frozen importlib._bootstrap>", line 983, in _find_and_load
django_1 | File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
django_1 | File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
django_1 | File "<frozen importlib._bootstrap_external>", line 728, in exec_module
django_1 | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
django_1 | File "/usr/local/lib/python3.7/site-packages/cms/models/__init__.py", line 4, in <module>
django_1 | from .permissionmodels import * # nopyflakes
django_1 | File "/usr/local/lib/python3.7/site-packages/cms/models/permissionmodels.py", line 21, in <module>
django_1 | User = apps.get_registered_model(user_app_name, user_model_name)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 273, in get_registered_model
django_1 | "Model '%s.%s' not registered." % (app_label, model_name))
django_1 | LookupError: Model 'users.User' not registered.
所以我一直在摆弄应用程序的加载顺序,但无济于事。
事实证明,两者是兼容的。我尝试了最新版本的 djangocms-installer 并手动将其与最新的 cookiecutter-django base 合并。
在 cookiecutter-django 的 base.py(设置)
...
LOCAL_APPS = [
"mysite.users.apps.UsersConfig",
]
DJANGO_CMS_APPS = [
"cms",
"menus",
"sekizai",
"treebeard",
"djangocms_text_ckeditor",
"filer",
"easy_thumbnails",
"djangocms_bootstrap4",
"djangocms_bootstrap4.contrib.bootstrap4_alerts",
"djangocms_bootstrap4.contrib.bootstrap4_badge",
"djangocms_bootstrap4.contrib.bootstrap4_card",
"djangocms_bootstrap4.contrib.bootstrap4_carousel",
"djangocms_bootstrap4.contrib.bootstrap4_collapse",
"djangocms_bootstrap4.contrib.bootstrap4_content",
"djangocms_bootstrap4.contrib.bootstrap4_grid",
"djangocms_bootstrap4.contrib.bootstrap4_jumbotron",
"djangocms_bootstrap4.contrib.bootstrap4_link",
"djangocms_bootstrap4.contrib.bootstrap4_listgroup",
"djangocms_bootstrap4.contrib.bootstrap4_media",
"djangocms_bootstrap4.contrib.bootstrap4_picture",
"djangocms_bootstrap4.contrib.bootstrap4_tabs",
"djangocms_bootstrap4.contrib.bootstrap4_utilities",
"djangocms_file",
"djangocms_icon",
"djangocms_link",
"djangocms_picture",
"djangocms_style",
"djangocms_snippet",
"djangocms_googlemap",
"djangocms_video",
"mysite",
]
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS + DJANGO_CMS_APPS
我为 Django-CMS 应用程序创建了另一个堆栈。安装应用程序的顺序很重要。所以 LOCAL_APPS 必须在 DJANGO_CMS_APPS.
之前加载
我在以前的版本中尝试过同样的方法,但仍然不知道为什么在那里失败了。希望这能有所帮助。
我刚刚尝试将我的 Django-CMS 项目移植到 Django Cookiecutter (cookiecutter-django) 中,以便在 Docker 中将其添加到 运行。
似乎 Django-CMS 使用的是默认的 Django 用户模型,而 Cookie-Cutter 使用的是自定义模型(来自 allauth?)。
我发现了这个 https://github.com/pydanny/cookiecutter-django/pull/248 帖子,它建议更改应用程序的加载顺序,但这并没有削减芥末。
Django-CMS 和 Cookiecutter 相互矛盾吗?
添加: 运行 Django 2.2.7 和 django-cms 3.7.2
编辑: 错误 message/traceback 当我 运行
$ docker-compose -f local.yml up
...
postgres_1 | 2020-04-22 13:58:12.315 UTC [1] LOG: database system is ready to accept connections
django_1 | PostgreSQL is available
django_1 | Traceback (most recent call last):
django_1 | File "manage.py", line 30, in <module>
django_1 | execute_from_command_line(sys.argv)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
django_1 | utility.execute()
django_1 | File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
django_1 | django.setup()
django_1 | File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
django_1 | apps.populate(settings.INSTALLED_APPS)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate
django_1 | app_config.import_models()
django_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models
django_1 | self.models_module = import_module(models_module_name)
django_1 | File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
django_1 | return _bootstrap._gcd_import(name[level:], package, level)
django_1 | File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
django_1 | File "<frozen importlib._bootstrap>", line 983, in _find_and_load
django_1 | File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
django_1 | File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
django_1 | File "<frozen importlib._bootstrap_external>", line 728, in exec_module
django_1 | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
django_1 | File "/usr/local/lib/python3.7/site-packages/cms/models/__init__.py", line 4, in <module>
django_1 | from .permissionmodels import * # nopyflakes
django_1 | File "/usr/local/lib/python3.7/site-packages/cms/models/permissionmodels.py", line 21, in <module>
django_1 | User = apps.get_registered_model(user_app_name, user_model_name)
django_1 | File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 273, in get_registered_model
django_1 | "Model '%s.%s' not registered." % (app_label, model_name))
django_1 | LookupError: Model 'users.User' not registered.
所以我一直在摆弄应用程序的加载顺序,但无济于事。
事实证明,两者是兼容的。我尝试了最新版本的 djangocms-installer 并手动将其与最新的 cookiecutter-django base 合并。
在 cookiecutter-django 的 base.py(设置)
...
LOCAL_APPS = [
"mysite.users.apps.UsersConfig",
]
DJANGO_CMS_APPS = [
"cms",
"menus",
"sekizai",
"treebeard",
"djangocms_text_ckeditor",
"filer",
"easy_thumbnails",
"djangocms_bootstrap4",
"djangocms_bootstrap4.contrib.bootstrap4_alerts",
"djangocms_bootstrap4.contrib.bootstrap4_badge",
"djangocms_bootstrap4.contrib.bootstrap4_card",
"djangocms_bootstrap4.contrib.bootstrap4_carousel",
"djangocms_bootstrap4.contrib.bootstrap4_collapse",
"djangocms_bootstrap4.contrib.bootstrap4_content",
"djangocms_bootstrap4.contrib.bootstrap4_grid",
"djangocms_bootstrap4.contrib.bootstrap4_jumbotron",
"djangocms_bootstrap4.contrib.bootstrap4_link",
"djangocms_bootstrap4.contrib.bootstrap4_listgroup",
"djangocms_bootstrap4.contrib.bootstrap4_media",
"djangocms_bootstrap4.contrib.bootstrap4_picture",
"djangocms_bootstrap4.contrib.bootstrap4_tabs",
"djangocms_bootstrap4.contrib.bootstrap4_utilities",
"djangocms_file",
"djangocms_icon",
"djangocms_link",
"djangocms_picture",
"djangocms_style",
"djangocms_snippet",
"djangocms_googlemap",
"djangocms_video",
"mysite",
]
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS + DJANGO_CMS_APPS
我为 Django-CMS 应用程序创建了另一个堆栈。安装应用程序的顺序很重要。所以 LOCAL_APPS 必须在 DJANGO_CMS_APPS.
之前加载我在以前的版本中尝试过同样的方法,但仍然不知道为什么在那里失败了。希望这能有所帮助。