Django2.0使用dos新建项目
由于本人的Pycharm不能直接生成Django项目,所以用命令行来生成项目,搭建此项目,请先搭建好环境
环境:PyCharm
Python3.5.2
Django 2.0
1.使用dos进入工作目录,执行django-admin.py startproject 项目名;如下
2,使用PyCharm打开新建好的项目,目录结构如下
3.在Pycharm工具中打开Terminal,新建一个名叫myApp的模块,命令为:python manage.py startapp myApp
Django开发环境就搭建好了
4.注册新建好的app,在settings.py中,找到INSTALLED_APPS,在后面追加你的app名称,如下:
5. 进入项目目录,执行python manage.py runserver
E:\PyCharmWork\PythonWebApp\ExciseDjangoWeb>python manage.py runserver Performing system checks... System check identified no issues (0 silenced). You have 14 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, s essions. Run 'python manage.py migrate' to apply them. December 27, 2017 - 15:18:25 Django version 2.0, using settings 'ExciseDjangoWeb.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. [27/Dec/2017 15:18:32] "GET / HTTP/1.1" 200 16559
6.输入http://127.0.0.1:8000/,看见如下界面,说明成功啦
用到的命令:django-admin.py startproject 项目名 ;使用Dos新建项目
python manage.py startapp app名称 ;进入新建项目,新建一个app
python manage.py runserver ; 运行该项目