A discussion on the Django of Python Web Framework (I.)

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

A discussion on the Django of Python web framework

Django is an open-source Web application framework written by Python. The MVC framework pattern was adopted, i.e. model M, view V and Controller C. It was originally developed to manage some of the news content-based websites of the Lawrence Publishing Group, namely CMS (Content management system) software. and was released in July 2005 under the BSD license. The framework is named after the Belgian gypsy jazz guitarist Django Reinhardt.

Django can run on Apache,nginx, or it can run on a server that supports wsgi,fastcgi. Support a variety of databases, has supported Postgresql,mysql, sqlite3,oracle. Google App Engine also supports some parts of Django, and the domestically supported platform has the (SAE) Sina app Engine, (BAE) Baidu application engines.

The Django project is a Python custom framework that originates from an online news Web site that was released in open source in 2005.

The core components of the Django framework are:

To create the object-relational mappings for the model

"The perfect management interface designed for end users

"First-class URL design

"Designer-friendly template language

"Cache system

Django (pronunciation: [' dɡ]) is an open source Web development framework (open source web framework) written in the Python language that encourages rapid development and follows MVC design. Django complies with BSD copyright, was first released in July 2005, and was released in September 2008 with the first official version 1.0. Django is named after Belgian jazz musician Django Reinhardt, a gypsy who mainly plays guitar, plays the violin and so on. Due to the rapid development of Django in recent years, the application is more and more extensive, the famous IT Development magazine SD Times 100, ranked in the "API, library and framework" category 6th, is considered to be the leader in this field.


================================================================================================

First, the Linux platform to build Django environment

================================================================================================

1. Linux system Environment

[Email protected] ~]# cat/etc/redhat-release

CentOS Linux release 7.3.1611 (Core)

[Email protected] ~]# uname-a

Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 16:42:41 UTC x86_64 x86_64 x86_64 gnu/linux

[Email protected] ~]# uname-r

3.10.0-514.el7.x86_64

[Email protected] ~]# uname-m

x86_64

2. Install Python

python2.7.5 has been built.

[[email protected] ~]# python

Python 2.7.5 (default, 4 2017, 00:39:18)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2

Type "Help", "copyright", "credits" or "license" for more information.

>>>

2. Install Pip

[Email protected] ~]# pip-v

Pip 9.0.1 From/usr/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg (Python 2.7)

3, Installation Setuptools

[Email protected] ~]# yum-y install Setuptools

4. Installing the Django Environment

[[email protected] ~]# Easy_install Django

or [[email protected] ~]# pip install Django

5. Test if Django is installed successfully

[Email protected] setuptools-36.5.0]# django-admin--version

1.11.5

Or

[[email protected] setuptools-36.5.0]# python

Python 2.7.5 (default, 4 2017, 00:39:18)

[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2

Type "Help", "copyright", "credits" or "license" for more information.

>>> Import Django

>>> django.get_version ()

' 1.11.5 '

"Update Address" http://doublelinux.blog.51cto.com/12300166/1965832


================================================================================================

Second, Django use

================================================================================================

1. Use Django to create a project named HelloWorld

[Email protected] setuptools-36.5.0]# cd/home/qiu/

[Email protected] qiu]# django-admin startproject HelloWorld

[[email protected] qiu]# ls

HelloWorld

2. Running the project HelloWorld

[Email protected] qiu]# CD helloworld/

[[email protected] helloworld]# ls

HelloWorld manage.py

[email protected] helloworld]# python manage.py runserver 192.168.255.128:8000

Performing system checks ...


System Check identified no issues (0 silenced).


You have unapplied migration (s). Your project properly until you apply the Migrations for app (s): admin, Auth, contenttypes, sessions.

Run ' python manage.py migrate ' to apply them.


September 16, 2017-06:27:28

Django version 1.11.5, using Settings ' helloworld.settings '

Starting development Server at Http://192.168.255.128:8000/

Quit the server with Control-c.

3. Firewall and SELinux settings

[Email protected] hello]# Systemctl stop Firewalld

[Email protected] hello]# Setenforce 0

4. Access in the browser

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/A5/66/wKioL1m8xOHS4OPDAADDJsZQ1UU304.png "title=" 799. PNG "alt=" Wkiol1m8xohs4opdaaddjszq1uu304.png "/>

Problems occurred


5, solve the problem

[Email protected] qiu]# cd/home/qiu/helloworld/

[[email protected] helloworld]# ls

Db.sqlite3 HelloWorld manage.py

[Email protected] helloworld]# CD helloworld/

[[email protected] helloworld]# ls

__init__.py __init__.pyc settings.py settings.pyc urls.py urls.pyc wsgi.py wsgi.pyc

[Email protected] helloworld]# vim settings.py

Modify allowed_hosts = [] to allowed_hosts = [' * ']

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/A5/66/wKioL1m8xZiwX3IsAAAUfyiH2vM616.png "title=" 330099.png "alt=" Wkiol1m8xziwx3isaaaufyih2vm616.png "/>

6, access to normal

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/06/B6/wKiom1m8xfnD5soWAABJgTeETkk210.png "title=" 992233.png "alt=" Wkiom1m8xfnd5sowaabjgteetkk210.png "/>

================================================================================================

Three

================================================================================================


This article from "Doublelinux" blog, declined reprint!

A discussion on the Django of Python Web Framework (I.)

Related Article

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.