安装Diango
命令: sudo pip install Django
错误:
root:bin xianglingchuan$ sudo pip install Django
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
The directory '/Users/root/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/root/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting Django
Downloading Django-2.0.tar.gz (8.0MB)
100% |████████████████████████████████| 8.0MB 25kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-build-fumLES/Django/setup.py", line 32, in <module>
version = __import__('django').get_version()
File "django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "django/utils/version.py", line 61, in <module>
@functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-fumLES/Django/
root:bin xianglingchuan$ sudo pip install Django==1.9
因为Django与python存在不兼容,命令修改为:
sudo pip install Django==1.9
创建项目
django-admin.py startproject dmosite
启动项目
python manage.py runserver 0.0.0.0:8002
目录说明:
manage.py: 一个实用的命令行工具,可让你以各种方式与该 Django 项目进行交互。
demosite/init.py: 一个空文件,告诉 Python 该目录是一个 Python 包。
demosite/settings.py: 该 Django 项目的设置/配置。
demosite/urls.py: 该 Django 项目的 URL 声明; 一份由 Django 驱动的网站”目录”。
demosite/wsgi.py: 一个 WSGI 兼容的 Web 服务器的入口,以便运行你的项目。