Django开发环境部署

安装pip
wget http://mirrors.laohulab.com:9000/Django/get-pip.py
./get-pip.py

Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 14kB/s
Collecting setuptools
Downloading setuptools-36.2.7-py2.py3-none-any.whl (477kB)
100% |████████████████████████████████| 481kB 12kB/s
Collecting wheel
Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB)
100% |████████████████████████████████| 71kB 12kB/s
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-9.0.1 setuptools-36.2.7 wheel-0.29.0
安装Django版本(1.10.4)
pip install django==1.10.4
Collecting django==1.10.4
Downloading Django-1.10.4-py2.py3-none-any.whl (6.8MB)
100% |████████████████████████████████| 6.8MB 14kB/s
Installing collected packages: django
Successfully installed django-1.10.4
安装Django REST framework
pip install djangorestframework
pip install markdown # Markdown support for the browsable API.
pip install django-filter # Filtering support

Add ‘rest_framework’ to your INSTALLED_APPS setting.
INSTALLED_APPS = (

‘rest_framework’,
)

If you’re intending to use the browsable API you’ll probably also want to add REST framework’s login and logout views. Add the following to your root urls.py file.
urlpatterns = [

url(r’^api-auth/‘, include(‘rest_framework.urls’, namespace=’rest_framework’))
]
Note that the URL path can be whatever you want, but you must include ‘rest_framework.urls’ with the ‘rest_framework’namespace. You may leave out the namespace in Django 1.9+, and REST framework will set it for you.

安装前端调试工具
pip install django-debugtools
Collecting django-debugtools
Downloading django_debugtools-1.7.2-py2.py3-none-any.whl
Installing collected packages: django-debugtools
Successfully installed django-debugtools-1.7.2
Configuration
Add the module to the installed apps:
INSTALLED_APPS += (
'debugtools',
)

As of Django 1.9, either use {% load debugtools_tags %} or add the following to the settings:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
# ...
],
'builtins': [ # Add this section
"debugtools.templatetags.debugtools_tags", # Add this line
],
},
},
]
0%