Django项目的导入及启动

1,安装viretualenv
2, 创建虚拟环境virtualenv venv
3,激活虚拟环境source venv/bin/activate
4,创建项目django-admin startproject demo
5,尝试运行项目venv/demo$ python manage.py runserver
提示ImportError: No module named 'django'
解决:pip3 install django -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
6,再次尝试运行$ python manage.py runserver
提示

      Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 17 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.

July 12, 2020 - 13:00:29
Django version 2.2.14, using settings 'demo.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

解决:$ python manage.py migrate
7,再次运行,搞定

$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).
July 12, 2020 - 13:01:16
Django version 2.2.14, using settings 'demo.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

你可能感兴趣的:(Django项目的导入及启动)