Django下载地址:
Django 1.5.x 支持 Python 2.6.5 Python 2.7, Python 3.2 和 3.3.
Django 1.6.x 支持 Python 2.6.X, 2.7.X, 3.2.X 和 3.3.X
Django 1.7.x 支持 Python 2.7, 3.2, 3.3, 和 3.4 (注意:Python 2.6 不支持了)
Django 1.8.x 支持 Python 2.7, 3.2, 3.3, 3.4 和 3.5. (长期支持版本 LTS)
Django 1.9.x 支持 Python 2.7, 3.4 和 3.5. 不支持 3.3 了
Django 1.10.x 支持 Python 2.7, 3.4 和 3.5.
Django 1.11.x 支持 Python 2.7, 3.4, 3.5 和 3.6(长期支持版本 LTS) 最后一个支持 Python 2.7 的版本
Django 2.0.x 支持 Python 3.4, 3.5 和 3.6 (注意,不再支持 Python 2)
我这里下载的是:Django-2.1.1.tar.gz
使用压缩工具解压至: D:\MyApps\Python\Django-2.1.1
检查Python是否安装好:C:\Users\admin>python -V
Python 3.4.4
CMD窗口中执行(python setup.py install):
(D:\MyApps\Python\Django-2.1.1\python setup.py install)D:\MyApps\Python\Django-2.1.1>python setup.py install
==========================
Unsupported Python version
==========================
This version of Django requires Python 3.5, but you're trying to
install it on Python 3.4.
This may be because you are using a version of pip that doesn't
understand the python_requires classifier. Make sure you
have pip >= 9.0 and setuptools >= 24.2, then try again:
$ python -m pip install --upgrade pip setuptools
$ python -m pip install django
This will install the latest version of Django which works on your
version of Python. If you can't upgrade your pip (or Python), request
an older version of Django:
$ python -m pip install "django<2"
Python版本太低,不支持。
切换成Python3.7:C:\Users\admin>python -V
Python 3.7.1rc1
CMD窗口中执行(python setup.py install):D:\MyApps\Python\Django-2.1.1>python setup.py install
......
Installed d:\myapps\python\python37\lib\site-packages\pytz-2018.5-py3.7.egg
Finished processing dependencies for Django==2.1.1
验证是否安装成功:D:\MyApps\Python\Django-2.1.1>python
Python 3.7.1rc1 (v3.7.1rc1:2064bcf6ce, Sep 26 2018, 15:15:36) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.VERSION
(2, 1, 1, 'final', 0)
>>> django.get_version()
'2.1.1'
>>>
安装完Django后,在Python根目录下的Scripts目录中:
(D:\MyApps\Python\Python37\Scripts)django-admin-script.py
django-admin.exe
easy_install-3.7.exe
easy_install.exe
pip.exe
pip3.7.exe
pip3.exe
将D:\MyApps\Python\Python37\Scripts目录配置到环境变量Path下。
运行"django-admin help",可以看到django的命令列表:C:\Users\admin> django-admin help
Type 'django-admin help ' for help on a specific subcommand.
Available subcommands:
[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALL
ED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call
settings.configure() before accessing settings.).