1. Install Django
Method One: After switching the source of the Epel.repo, Django1.6 was installed using sudo yum install Django.
Method Two: Can also use Pip install Django, but my CentOS7 did not install PIP, first installed Pip:sudo yum install Python-pip can, in addition, I currently use the python2.7.x, if it is python3 words need PIP3.
Method III: Install Git,sudo yum install git; git clone https://github.com/django/django.git
Method four: Download django.tar.gz from official website, execute tar zxvf unpack, python setup.py install
See the Detailed method: Rookie tutorial Http://www.runoob.com/django/django-install.html
2. Create the Project
Django-admin Startproject Project Name ProjectName
3. Create an application (such as a blog)
Django-admin Startapp Blog
4. configuration File Settings
Vim settings.py
Time-zone = ' Asia/shanghai '
LANGUAGE CODE = ' ZH-CN '
Last added in installed APPS
' Blog ', # Pay special attention to write commas (tuples)
5. Create a map
Vim urls.py
Add to
URL (r ' ^blog/index/$ ', ' Blog.views.index ')
To map a URL ending with blog/index/to the index method in a views.py file, even with a regular expression
6. Establish a method (function)
Vim blog/views.py
From django.http import HttpResponse
def index (req):
Return HttpResponse ('
7. Start the development server, test
Python manager.py runserver
Browser access: 127.0.0.1:8000/blog/index
Note Get the error message from the error404 page and adjust the configuration to restart the development server.