1. 环境安装
1).virtualenv安装
C:\Users\Administrator>pip install virtualenv Collecting virtualenv Using cached https://files.pythonhosted.org/packages/b6/30/96a02b2287098b23b875bc8c2f58071c35d2efe84f747b64d523721dc2b5/virtualenv-16.0.0-py2.py3-none-any.whl Installing collected packages: virtualenv Successfully installed virtualenv-16.0.0
2). 建立虚拟环境
D:\work\env>virtualenv django_env New python executable in D:\work\env\django_env\Scripts\python.exe Installing setuptools, pip, wheel...done.
3).进入虚拟环境并安装django
D:\work\env\django_env\Scripts>activate (django_env) D:\work\env\django\Scripts>pip install django Collecting django Using cached https://files.pythonhosted.org/packages/bf/e0/e659df5b5b82299fffd8b3df2910c99351b9308b8f45f5702cc4cdf946e9/Django-1.11.14-py2.py3-none-any.whl Collecting pytz (from django) Using cached https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl Installing collected packages: pytz, django Successfully installed django-1.11.14 pytz-2018.5
2. pycharm创建django项目
1)创建项目
2) 项目结构
上面djangoProject:项目名称,可修改
apps:项目名称,如果分多个模块,通常放在该目录下
tests:应用下单元测试用例
views:应用视图函数
下面djangoProject:项目实际的python,最好不要修改,涉及配置问题
settings:项目全局配置文件
urls:项目全局路由
wsgi:项目wsgi配置
template:配置模板文件
manage:程序入口
原文地址:https://www.cnblogs.com/cloudman-open/p/9256501.html
时间: 2024-11-08 15:29:24