Django Notes Collation 1

Source: Internet
Author: User
Tags install django pip install django git clone

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.