【问题标题】:Django SystemCheckError: System check identified some issues:Django SystemCheckError:系统检查发现了一些问题:
【发布时间】:2022-08-21 16:31:53
【问题描述】:

再会。使用 Django REST 框架创建项目https://github.com/LeonidPrice/advertisementboard 启动服务器时出现以下错误: (所有迁移都已完成)

 (board) D:\\python_projects\\board\\board>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File \"C:\\Program Files\\Python310\\lib\\threading.py\", line 1009, in _bootstrap_inner
    self.run()
  File \"C:\\Program Files\\Python310\\lib\\threading.py\", line 946, in run
    self._target(*self._args, **self._kwargs)
  File \"D:\\python_projects\\board\\board\\lib\\site-packages\\django\\utils\\autoreload.py\", line 64, in wrapper
    fn(*args, **kwargs)
  File \"D:\\python_projects\\board\\board\\lib\\site-packages\\django\\core\\management\\commands\\runserver.py\", line 134, in inner_run
    self.check(display_num_errors=True)
  File \"D:\\python_projects\\board\\board\\lib\\site-packages\\django\\core\\management\\base.py\", line 558, in check
    raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:

ERRORS:
?: (captcha.recaptcha_test_key_error) RECAPTCHA_PRIVATE_KEY or RECAPTCHA_PUBLIC_KEY is making use of the Google test keys and will not behave as expected in a production environment     
        HINT: Update settings.RECAPTCHA_PRIVATE_KEY and/or settings.RECAPTCHA_PUBLIC_KEY. Alternatively this check can be ignored by adding `SILENCED_SYSTEM_CHECKS = [\'captcha.recaptcha_test_key_error\']` to your settings file.

WARNINGS:
main.AdditionalImage: (models.W042) Auto-created primary key used when not defining a primary key type, by default \'django.db.models.AutoField\'.
        HINT: Configure the DEFAULT_AUTO_FIELD setting or the MainConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. \'django.db.models.BigAutoField\'.
main.AdvUser: (models.W042) Auto-created primary key used when not defining a primary key type, by default \'django.db.models.AutoField\'.
        HINT: Configure the DEFAULT_AUTO_FIELD setting or the MainConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. \'django.db.models.BigAutoField\'.
main.Board: (models.W042) Auto-created primary key used when not defining a primary key type, by default \'django.db.models.AutoField\'.
        HINT: Configure the DEFAULT_AUTO_FIELD setting or the MainConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. \'django.db.models.BigAutoField\'.
main.Comment: (models.W042) Auto-created primary key used when not defining a primary key type, by default \'django.db.models.AutoField\'.
        HINT: Configure the DEFAULT_AUTO_FIELD setting or the MainConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. \'django.db.models.BigAutoField\'.
main.Rubric: (models.W042) Auto-created primary key used when not defining a primary key type, by default \'django.db.models.AutoField\'.
        HINT: Configure the DEFAULT_AUTO_FIELD setting or the MainConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. \'django.db.models.BigAutoField\'.
main.SubRubric: (models.W042) Auto-created primary key used when not defining a primary key type, by default \'django.db.models.AutoField\'.
        HINT: Configure the DEFAULT_AUTO_FIELD setting or the MainConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. \'django.db.models.BigAutoField\'.
main.SuperRubric: (models.W042) Auto-created primary key used when not defining a primary key type, by default \'django.db.models.AutoField\'.
        HINT: Configure the DEFAULT_AUTO_FIELD setting or the MainConfig.default_auto_field attribute to point to a subclass of AutoField, e.g. \'django.db.models.BigAutoField\'.

System check identified 8 issues (0 silenced).

请告诉我是什么问题以及如何解决?

    标签: python django django-rest-framework captcha traceback


    【解决方案1】:

    安装很棒的 django-recaptcha 并按照说明进行操作。确保至少添加以下设置。

    RECAPTCHA_PUBLIC_KEY = 'key'
    RECAPTCHA_PRIVATE_KEY = 'secret'
    NOCAPTCHA = True
    
    #Now you can simply add the captcha field to a form.
    
    from django import forms
    from django.conf import settings
    from captcha.fields import ReCaptchaField
    
    class ReCAPTCHAForm(forms.Form):
        captcha = ReCaptchaField()
    

    您似乎忘记在 settings.py 文件中添加设置 RECAPTCHA_PRIVATE_KEY 或 RECAPTCHA_PUBLIC_KEY 了。

    你可以在这里找到完整的解释DJANGO

    【讨论】:

      猜你喜欢
      • 2021-01-13
      • 2017-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-06
      • 2018-01-20
      相关资源
      最近更新 更多