Install Django on ubuntu

1、 Introduction

Django is a web development framework that can make web development work pleasant and efficient. Using Django enables you to build and maintain high-quality Web applications with minimal cost.

Django features

Powerful data function: Has a powerful database operation interface (QuerySet API), and can execute native SQL if necessary.

Comes with a powerful backend: A few lines of simple code will let your website have a powerful backend and manage content easily!

Elegant URL: match the URL with regularity, pass it to the corresponding function, and define it at will, as you want!

Template system: powerful, easy to expand template system, simple design, separate design of code and style, easier to manage.

Note: When the front and back ends are separated, you can also use Django to develop APIs without the template system at all.

Cache system: combined with Memcached, Redis and other cache systems, better performance and faster loading speed.

Internationalization: Fully supports multi-language applications, allowing you to define the characters for translation, and easily translate into languages of different countries.

The following is the architecture diagram of Django:

Django overview:

**url.py: **URL entry, associated with a function (or generic class) in the corresponding views.py, access to the URL corresponds to a function.

**views.py: **Processing the user's request, corresponding from urls.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: **Forms, users enter data on the browser to submit, verify data, and generate input boxes, etc. Of course, you don’t need to use it.

**Templates folder: The function in **views.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.

2、 Django environment setup

Use pip to install

1 ), install python and pip

To install Python, we must first update the local APT repository. In your terminal window, we will enter the following commands. Please note that the -y flag answers the "yes" prompt during the upgrade process. If you want to upgrade to stop for each prompt, remove the flag.

sudo apt-get install python3

To verify the successful installation of Python 3, use the python3 command to run a version check:

python3 -V

The resulting output will be similar to:

Now that we have installed Python 3, in order to install the package from PyPi, Python's package repository, we also need the version.

sudo apt-get install -y python3-pip

To verify that pip has been successfully installed, run the following command:

pip3 -V

You can see similar output:

2 ), install Django

There are three ways to install Django. We will use the pip installation method of this tutorial, but we will introduce all available options for reference.

Using pip to install Django requires a line of commands, as shown below: (I made an error when installing Django here. It is a problem with the official source of pip. Modify it to Douban source:

The official source of ubuntu modified pip is Douban source

sudo pip3 install django

If you want to upgrade pip, you can use it (I suggest that the pip version is low and you need to upgrade):

( sudo) pip install --upgrade pip

If an error occurs during the installation process, the prompt is:

It is usually due to the network, and the download of Django is unsuccessful!

Just try a few more times! ! !

Once installed, verify your Django installation by running a version check:

django-admin --version

(Unfinished...)

Reference materials: https://www.cnblogs.com/rainsoul/p/7730390.html

Recommended Posts

Install Django on ubuntu
install vscode on ubuntu18
Install nvtop on Ubuntu 18.04
Install postgresql-10 on Ubuntu 18.04
Install docker on Ubuntu
Install nodejs10 on Ubuntu16
Install mysql on Ubuntu 14.04
Install Pytorch+CUDA on Ubuntu 16.04
Install Python3 on Ubuntu 14.04
Install rJava on Ubuntu18
Install JDK10+ on Ubuntu
Install Python3 on Ubuntu 16.04
Install KDE on Ubuntu16.04.2
Install Docker on Ubuntu18
Install Python3.7 on Ubuntu
Install flashplayer on Ubuntu
Docker practice (1): install Docker on Ubuntu 16.04
Install ubuntu on virtual machine
Install OpenSSL 1.0.2 on Ubuntu Server 14.04
Install QQ robot on Ubuntu 16.04
Install Python 3.7 on Ubuntu 18.04 LTS
Install Android Studio on Ubuntu
Install scrapy framework on ubuntu
Install Mysql offline on Ubuntu
Install Oracle Java8 on Ubuntu
How to install Django Web Framework on Ubuntu 18.04
Install Odoo 11 stack on Ubuntu 16.04
Install Go locale on Ubuntu16
Install common software on Ubuntu 16.04
Install non-portable QQ on ubuntu
Install Docker on Ubuntu 18.04 offline
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
Install and configure MySQL on Ubuntu
Install Chef server workstation on Ubuntu 18.04
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
Install botan2 encryption library on ubuntu
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
Docker ubuntu: install python-PIL-image environment on 14.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04
How to install PrestaShop on Ubuntu 16.04
How to install Skype on Ubuntu 20.04
How to install Jenkins on Ubuntu 20.04