无法安装django_messages应用

时间:2018-08-14 08:22:23

标签: python django django-messages

我尝试安装django_messages

我将文件夹复制到目录中并运行以下命令:

python manage.py makemigrations

错误是这样的:

C:\Users\Admin\Desktop\sample\enginesearch1>python manage.py runserver
Performing system checks...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000025D3C50A488>
Traceback (most recent call last):
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\management\base.py", line 410, in check
    raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
django_messages.Message.sender: (fields.E320) Field specifies on_delete=SET_NULL, but cannot be null.
        HINT: Set null=True argument on the field, or change the on_delete rule.

这是什么问题,我应该在哪里更改?

1 个答案:

答案 0 :(得分:0)

在您的Message模块中(在models.py中),您可能输入了一个名为sender的字段。 您不能设置空值,因此请参见以下示例:

field = models.ForeignKey(File, null=True, blank=True,on_delete=models.SET_NULL)