Django provides modules that are often used to develop websites. The common code is written for you. By reducing repetitive code, Django enables you to focus on interesting and key things in web applications. In order to achieve this goal, Django provides a high degree of abstraction of common web development models, provides quick solutions to frequently performed programming tasks, and provides clear conventions for "how to solve problems". Django's philosophy is DRY (Don't Repeat Yourself) to encourage rapid development!
urls.py
URL entry, linked to the corresponding views.A function (or generic class) in py corresponds to a function when accessing the URL.
views.py
Process user requests from urls.Corresponding in py,By rendering the web page in templates, the displayed content, such as the user name after logging in, and the data requested by the user, can be output to the web page.
models.py
Related to database operations, this is used when storing or reading data. Of course, you don't need to use it when you don't need the database.
forms.py
Form, the user enters the data on the browser to submit, the verification of the data and the generation of the input box, of course, you don’t need to use it.
templates folder
views.The function in py renders the Html template in templates to get dynamic content web pages. Of course, cache can be used to improve the speed.
admin.py
Backend, you can have a powerful backend with a small amount of code.
settings.py
Django settings, configuration files, such as DEBUG switch, location of static files, etc.
echo 'LANG="en_GB.utf8"'>/etc/sysconfig/i18n && cat /etc/sysconfig/i18n
reference
Centos firewall & SELINUX shutdown and yum source configuration
yum -y install openssl-devel readline-devel unzip gcc
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
tar -xvf Python-3.6.1.tgz
cd Python-3.6.1./configure --prefix=/usr/local/python36
make && make install
$ ll /usr/local/python36/bin/
Total amount 24660
lrwxrwxrwx 1 root root 812 Dec 1215:36 2to3 -> 2to3-3.6-rwxr-xr-x 1 root root 110 Dec 1215:36 2to3-3.6-rwxr-xr-x 1 root root 25 112 December 1215:36 easy_install-3.6
lrwxrwxrwx 1 root root 712 Dec 1215:36 idle3 -> idle3.6-rwxr-xr-x 1 root root 108 Dec 1215:36 idle3.6-rwxr-xr-x 1 root root 223 1215:36 pip3
- rwxr-xr-x 1 root root 223 1215:36 pip3.6
lrwxrwxrwx 1 root root 812 Dec 1215:36 pydoc3 -> pydoc3.6-rwxr-xr-x 1 root root 93 Dec 1215:36 pydoc3.6
lrwxrwxrwx 1 root root 912 Dec 1215:36 python3 -> python3.6-rwxr-xr-x 2 root root 12603760 December 1215:35 python3.6
lrwxrwxrwx 1 root root 17 Dec 1215:36 python3.6-config -> python3.6m-config
- rwxr-xr-x 2 root root 12603760 December 1215:35 python3.6m
- rwxr-xr-x 1 root root 310612 December 1215:36 python3.6m-config
lrwxrwxrwx 1 root root 16 Dec 1215:36 python3-config -> python3.6-config
lrwxrwxrwx 1 root root 10 Dec 1215:36 pyvenv -> pyvenv-3.6-rwxr-xr-x 1 root root 450 Dec 1215:36 pyvenv-3.6-rwxr-xr-x 1 root root 230 Dec 1215:39 virtualenv
vim /etc/pip.conf
[ global]
index-url = http://pypi.douban.com/simple/
trusted-host=pypi.douban.com
[ list]
format=columns
/usr/local/python36/bin/pip3 list
Package Version
-----------------
pip 9.0.1
setuptools 28.8.0
/usr/local/python36/bin/pip3 install virtualenv
Collecting virtualenv
Downloading http://pypi.doubanio.com/packages/6f/86/3dc328ee7b1a6419ebfac7896d882fba83c48e3561d22ddddf38294d3e83/virtualenv-15.1.0-py2.py3-none-any.whl(1.8MB)100%|████████████████████████████████|1.8MB 983kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-15.1.0
Create a normal user
useradd devops
passwd devops
Switch to normal devops
su - devops
/usr/local/python36/bin/virtualenv ./python36env
Using base prefix '/usr/local/python36'
New python executable in/home/devops/python36env/bin/python3.6
Also creating executable in/home/devops/python36env/bin/python
Installing setuptools, pip, wheel...done.
Enter the virtual environment
source python36env/bin/activate(python36env)[devops@devops-python36 ~]$ pip list
Package Version
-----------------
pip 9.0.1
setuptools 38.2.4
wheel 0.30.0
Django 1.5.x supports Python 2.6.5 Python 2.7, Python 3.2 and 3.3.
Django 1.6.x supports Python 2.6.X,2.7.X,3.2.X and 3.3.X
Django 1.7.x supports Python 2.7,3.2,3.3,And 3.4 (Note: Python 2.6 is not supported)
Django 1.8.x supports Python 2.7,3.2,3.3,3.4 and 3.5.(Long-term support version LTS)
Django 1.9.x supports Python 2.7,3.4 and 3.5.Does not support 3.3 out
Django 1.10.x supports Python 2.7,3.4 and 3.5.
Django 1.11.x supports Python 2.7,3.4,3.5 and 3.6 (Long-term support version LTS)The last one supports Python 2.Version 7
Django 2.0.x supports Python 3.4,3.5 and 3.6 (note that Python 2 is no longer supported)
pip install "django>=1.11(python36env)[devops@devops-python36 ~]$ pip install "django>=1.11,<=1.12"
Collecting django<=1.12,>=1.11
Downloading http://pypi.doubanio.com/packages/7e/36/5266e0c51ee9b953d60ea8ea1fea10e268b1368f9c0ad08e2ff76ee9c1b5/Django-1.11.8-py2.py3-none-any.whl(6.9MB)100%|████████████████████████████████|7.0MB 1.9MB/s
Collecting pytz(from django<=1.12,>=1.11)
Downloading http://pypi.doubanio.com/packages/a3/7f/e7d1acbd433b929168a4fb4182a2ff3c33653717195a26c1de099ad1ef29/pytz-2017.3-py2.py3-none-any.whl(511kB)100%|████████████████████████████████| 512kB 1.4MB/s
Installing collected packages: pytz, django
Successfully installed django-1.11.8 pytz-2017.3
Database installation reference
Centos7.5 install mysql5.7.24 binary package deployment
( python36env)[devops@devops-python36 ~]$ pip install pymysql
Collecting pymysql
Downloading http://pypi.doubanio.com/packages/c6/42/c54c280d8418039bd2f61284f99cb6d9e0eae80383fc72ceb6eac67855fe/PyMySQL-0.7.11-py2.py3-none-any.whl(78kB)100%|████████████████████████████████| 81kB 2.6MB/s
Installing collected packages: pymysql
Successfully installed pymysql-0.7.11(python36env)[devops@devops-python36 ~]$ pip list
Package Version
-----------------
Django 1.11.8
pip 9.0.1
PyMySQL 0.7.11
pytz 2017.3
setuptools 38.2.4
wheel 0.30.0
yum -y install vim
vim ~/.vimrc
set tabstop=4set shiftwidth=4set softtabstop=4set expandtab
set fileformat=unix
set nobomb
set ff=unix
set ambiwidth=double
set fileencodings=utf-8,ucs-bom,cp936
syntax on
filetype plugin on
set nocompatible
set completeopt=preview
set ai
set hls
set nu
Recommended Posts