從命令行運行django數據庫操作


從命令行運行django數據庫操作,報錯:

django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

看settings.py沒有問題

解決的方法:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

注意這個是不行的:
from django.conf import settings
settings.configure()

兩者都寫也是不行的


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM