One, the Python Django installation
One, the Django installation
# wget https://www.djangoproject.com/m/releases/1.3/Django-1.3.7.tar.gz--no-check-certificate
# TAR-ZXVF Django-1.3.7.tar.gz
# CD Django-1.3.7
# python setup.py Install
# python
Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "Help", "copyright", "credits" or "license" for more information.
>>> Import Django
>>>
Ii. Creation of the project
# django-admin.py Startproject csvt01
# CD CSVT01/
# ls
__init__.py (Package) manage.py (management tool) settings.py (current project configuration) urls.py (URL profile)
Third, add the application
# VI setting.py
Time_zone = ' Asia/shanghai '
Language_code = ' ZH-CN '
Installed_apps = (
' Django.contrib.auth ',
' Django.contrib.contenttypes ',
' Django.contrib.sessions ',
' Django.contrib.sites ',
' Django.contrib.messages ',
' Django.contrib.staticfiles ',
' Blog ', #自定义一个应用, Add user-defined apps here
)
Iv. Modifying the Access URL
# VI urls.py
Urlpatterns = Patterns ("',
URL (r ' ^blog/index/$ ', ' Blog.views.index '),
)
V. Launch the application
# django-admin.py Startapp Blog
# ls Blog
__init__.py (Package) models.py (model file) tests.py (test file) views.py (depending on graphics)
Vi. Adding view Files
# Vim blog/views.py
From django.http import HttpResponse
def index (req):
Return HttpResponse ('
Seven, through the Nginx proxy forwarding 8000 port
# vi/etc/nginx/conf.d/django.conf
server {
Listen default_server;
server_name _;
Location/{
Proxy_pass http://127.0.0.1:8000;
}
}
Viii. Commencement of Works
# python manage.py runserver
Validating models ...
0 errors found
Django version 1.3.7, using Settings ' csvt01.settings '
Development server is running at http://127.0.0.1:8000/
Quit the server with Control-c.
[09/aug/2016 16:42:28] "get/blog/index/http/1.0" 200 22
# nohup python manage.py runserver &
(Django is started in the background)
Open http://192.168.116.129/blog/index/via browser
This article is from "Meteor Yu" blog, please be sure to keep this source http://8789878.blog.51cto.com/8779878/1839700
One, the Python Django installation