第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Django DB設置“配置不正確”錯誤

Django DB設置“配置不正確”錯誤

冉冉說 2019-11-06 10:27:39
Django(1.5)對我來說很好用,但是當我啟動Python解釋器(Python 3)進行檢查時,嘗試導入時會遇到最奇怪的錯誤from django.contrib.auth.models import User--Traceback (most recent call last):  File "/usr/local/lib/python3.2/dist-packages/django/conf/__init__.py", line 36, in _setup    settings_module = os.environ[ENVIRONMENT_VARIABLE]  File "/usr/lib/python3.2/os.py", line 450, in __getitem__    value = self._data[self.encodekey(key)]KeyError: b'DJANGO_SETTINGS_MODULE'During handling of the above exception, another exception occurred:Traceback (most recent call last):  File "<stdin>", line 1, in <module>  File "/usr/local/lib/python3.2/dist-packages/django/contrib/auth/models.py", line 8, in <module>    from django.db import models  File "/usr/local/lib/python3.2/dist-packages/django/db/__init__.py", line 11, in <module>    if settings.DATABASES and DEFAULT_DB_ALIAS not in settings.DATABASES:  File "/usr/local/lib/python3.2/dist-packages/django/conf/__init__.py", line 52, in __getattr__    self._setup(name)  File "/usr/local/lib/python3.2/dist-packages/django/conf/__init__.py", line 45, in _setup    % (desc, ENVIRONMENT_VARIABLE))django.core.exceptions.ImproperlyConfigured: Requested setting DATABASES,   but settings are not configured. You must either define the environment   variable DJANGO_SETTINGS_MODULE or call settings.configure()   before accessing settings.當它在Python解釋器之外可以正常工作時,如何對其進行不正確的配置?在我的Django設置中,DATABASES設置為:DATABASES = {    'default': {        'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.        'NAME': 'django_db', # Or path to database file if using sqlite3.        # The following settings are not used with sqlite3:        'USER': 'zamphatta',        'PASSWORD': 'mypassword91',        'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.        'PORT': '', # Set to empty string for default.    }}...這是如何配置不正確的?
查看完整描述

3 回答

?
LEATH

TA貢獻1936條經驗 獲得超7個贊

在您的python shell / ipython中執(zhí)行以下操作:


from django.conf import settings


settings.configure()


查看完整回答
反對 回復 2019-11-06
  • 3 回答
  • 0 關注
  • 700 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號