gpt4 book ai didi

python - 在 INSTALLED_APPS 中添加 "moderation"时出错

转载 作者:行者123 更新时间:2023-12-01 08:27:40 26 4
gpt4 key购买 nike

我想在我的 Django 项目中使用 django-moderation。我已经使用 pip3 下载了该应用程序,问题是当我将应用程序添加到 INSTALLED_APPS 时,出现以下异常。您能告诉我如何摆脱这个吗?

python3 manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x1024977b8>
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 112, in inner_run
autoreload.raise_last_exception()
File "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 327, in execute
autoreload.check_errors(django.setup)()
File "/usr/local/lib/python3.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.7/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "/usr/local/lib/python3.7/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.7/site-packages/moderation/models.py", line 41, in <module>
class ModeratedObject(models.Model):
File "/usr/local/lib/python3.7/site-packages/moderation/models.py", line 43, in ModeratedObject
editable=False)
TypeError: __init__() missing 1 required positional argument: 'on_delete

最佳答案

最新发布Django-moderation是 2017 年的,所以不支持 Django 2。

拉取请求 #169 Django 2 已被合并,但此后一直没有发布。您可以尝试在 master 分支上安装最新的提交,例如:

pip install git+git://github.com/dominno/django-moderation.git@565481f1832114da2d0c48b0c23977d4d3a9b914

(在您的情况下,您将使用 pip3 而不是 pip,但开始使用虚拟环境而不是系统 Python 是一个好主意。一旦您已激活 Python 3 虚拟环境,您使用 pythonpip 而不是 python3pip3

关于python - 在 INSTALLED_APPS 中添加 "moderation"时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54119072/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com