【问题标题】:django.core.exceptions.ImproperlyConfigured: Requested setting REST_FRAMEWORKdjango.core.exceptions.ImproperlyConfigured:请求设置 REST_FRAMEWORK
【发布时间】:2021-03-03 10:27:50
【问题描述】:

为什么我在运行测试时会出现以下问题?已经尝试了一切,似乎没有任何效果 django.core.exceptions.ImproperlyConfigured: Requested setting REST_FRAMEWORK, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

一切正常,但正在测试中。

【问题讨论】:

    标签: django api


    【解决方案1】:

    在项目设置文件中检查您已安装的应用,并确保您添加了REST_FRAMEWORK,并且它不包含重复项或其他错误

    【讨论】:

    • 这是我安装的应用程序:INSTALLED_APPS = [ 'users', 'api', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', ' django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','rest_framework','rest_framework.authtoken','rest_framework_simplejwt','django_filters','corsheaders',]一切都很好
    • 他们看起来没问题,错误声明提到了You must either define the environment variable DJANGO_SETTINGS_MODULEcheck this out if it will solve your problem
    猜你喜欢
    • 2018-05-17
    • 2018-05-21
    • 2020-04-12
    • 2015-04-16
    • 2021-08-07
    • 2020-08-25
    • 1970-01-01
    • 2021-10-04
    • 2014-07-23
    相关资源
    最近更新 更多