解決“django.core.exceptions.improperlyconfigured”錯誤
在你的代碼中,遇到了 “django.core.exceptions.improperlyconfigured: ‘django.db.backends.mysql‘ isn’t an available database backend” 錯誤。這表明 django 無法導入 mysql 后端。
原因
問題在于你的代碼實際運行在 python 3.8 而非 3.7 上。python 3.8 中不再內置 mysql 后端。
解決方案
要解決此問題,需要使用第三方包來安裝 mysql 后端。具體步驟如下:
- 使用 pip 安裝 mysqlclient:
pip install mysqlclient
- 修改 settings.py 中的 databases 設置:
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', ... } }
- 確保使用正確的數據庫憑據。
重新運行服務器,錯誤應得到解決。
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END