新手Python和Django编码器
我正在尝试应用一些注册插件所需的迁移文件(django-registration-redux == 1.3)。但是,当我运行 python manage.py migration 命令时,出现以下错误
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "//Projects/hellowebapp/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "//Projects/hellowebapp/venv/lib/python3.7/site-packages/django/core/management/__init__.py", line 347, in execute
django.setup()
File "//Projects/hellowebapp/venv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "//Projects/hellowebapp/venv/lib/python3.7/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "//Projects/hellowebapp/venv/lib/python3.7/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "//Projects/hellowebapp/venv/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 "//Projects/hellowebapp/venv/lib/python3.7/site-packages/registration/models.py", line 206, in <module>
class RegistrationProfile(models.Model):
File "//Projects/hellowebapp/venv/lib/python3.7/site-packages/registration/models.py", line 222, in RegistrationProfile
user = models.OneToOneField(UserModelString(), verbose_name=_('user'))
TypeError: __init__() missing 1 required positional argument: 'on_delete'
不确定如何解决此错误或完全理解其含义。
答案 0 :(得分:1)
快速浏览django-registration-redux
文档(https://django-registration-redux.readthedocs.io/en/latest/quickstart.html)之后,我建议将其更新至该软件包的最新版本,即2.5。我大多数时候都发现这种类型的错误问题与django设置有关,即是否添加了正确的中间件,INSTALLED_APPS
等,希望对我有所帮助。