报错如下:
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
建议:
1、在终端建立虚拟环境
python -m venv venv
2、激活环境:
.\venv\Scripts\activate
(1)这时候可能会报错:You have 1 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): auth.
Run 'python manage.py migrate' to apply them.
这时候运行python manage.py migrate就行了
(2)还有这种错误:(fields.E210) Cannot use ImageField because Pillow is not installed.
这时候需要输入以下代码:
pip install pillow
(3)运行后页面中可能会有这种错误:'staticfiles' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache i18n l10n log static tz
这是因为在django3.x
中这部分做了修改,只需把{% load staticfiles %}统一修改成{% load static %}就可以了。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)