Django profile

Django is an open source, large and complete Web application framework written in Python. He adopted the MVC pattern, what is MVC? Don’t worry, MVC is such a good thing I will talk about it in detail below! Django was originally developed to manage some of the Lawrence Publishing Group’s news-focused web sites. A CMS (content management system) software. It was released under the BSD license in July 2005. The frame is named after Belgian gypsy jazz guitarist Django Reinhardt.

Django version

Django version has been updated to Django3.0.5, download website https://www.djangoproject.com/download/

The latest version of Django

Speaking of Django version, we have to mention python version. Before python 3.8 has passed, we need to update 叒 yi to Python. Recently, version 3.9 (www.python.org/downloads/r… Alpha is now open source. From the documentation, we can see the official release of new features for dict, Math, and other components, as well as the next steps in development.

Latest Version of Python

Django advantages

Powerful database function

With Python’s class inheritance, you can have a rich, dynamic database manipulation API (API) in a few lines of code, and execute SQL ORM statements if you need them. It decouples the data model from the database, that is, the design of the data model does not need to depend on a specific database, and the database can be easily replaced through simple configuration

It has powerful background functions

In admin.py, write the code you need to implement the functionality, and a few lines of code will make your administrator dreams come true. No more worrying about design administrators!

Elegant web site

Use the re to match urls in urls.py, pass it to the corresponding function, and you can define the url as you wish, as you wish. (Note that re is a separate syntax, not language owned.)

Have a template system

Templating greatly reduces the probability of developer headaches. Because the template system design is simple, easy to expand. Code, style separate design. Find more clear, easy to modify!

Caching system

Django works with memcached, Redis, or other caching systems to speed up page loading. Let the user experience better!

The templates function in the views.py folder renders the Html templates in templates to create a web page with dynamic content, although caching can be used to speed things up.

internationalization

It’s hard not to go global for such a good thing. You want the page to display in different languages, such as Chinese, English, and various languages. It just needs to be changed a little bit in the Settings of a file. Pages will be dressed in languages.

Djangos App concept is good.

App can be pluggable, is a rare idea. If no, you can delete it directly, which has little impact on the system.

How’s that? Is Django unimaginably powerful? But don’t get too excited. Because the code still needs to be written, it’s just much faster and easier to develop websites with Django!

Django has the following features:

  • Perfect function, complete elements: should have, can not have, commonly used, not commonly used tools are used. Django offers a plethora of features and tools that you dont need to define, combine, add, delete, or modify yourself. However, in the eyes of some people it is considered ‘bloated’ and not flexible enough to take the initiative of the programmer. Which do you prefer, all-in-one or DIY? ^ – ^)
  • Perfect documentation: After more than a decade of development and improvement, Django has extensive practice and complete online documentation (mostly in English, unfortunately). Developers with problems can search online documentation for solutions.
  • Powerful database access components: Django’s Model layer comes with a database ORM component that eliminates the need to learn other database access techniques (SQL, Pymysql, SQLALchemy, etc.). You can also use other access techniques, such as SQLALchemy, instead of using Django’s ORM.
  • Flexible URL mapping: Django uses regular expressions to manage URL mappings for flexibility.
  • Rich Template language: Similar to Jinjia Template language, rich in native features and the ability to customize Template tags.
  • Its own free background management system: only through a few lines of simple configuration and code can achieve a complete background data management control platform.
  • Complete error messages: Django provides a very complete error message to help you locate the problem if you encounter a runtime error or exception during debugging.

Okay, let’s start with MVC, MVT, ORM

Most development languages have MVC

The core idea of the MVC framework is decoupling. That is, the design of the data model does not depend on a specific database, and the database can be easily replaced with a simple configuration

Reduce the coupling between the functional modules, facilitate the change, easier to reconstruct the code, achieve the maximum reuse of the code

M stands for Model, mainly used to encapsulate the database layer

V stands for View, which is used to show the results to the user

C stands for Controller and is the core for processing requests, retrieving data, and returning results

M stands for Model, V for View, and C for Contrle.

MVT

Django is a Web development framework for Python

Different from MVC, it belongs to the MVT framework. But I can’t think of a better phrase.)

M stands for Model, responsible for interacting with the database

V stands for View and is the core responsible for receiving requests, obtaining data, and returning results

T stands for template, which is responsible for rendering content to the browser

What is ORM?

 

Let me give you a picture:

 

Finally, here’s a look at the core modules in Django: Stick with it

Django core Modules

urls.py

Url entry, associated with a function (or generic class) in views.py, and a function for accessing the url. Be careful when setting up functions.

views.py

Processing user requests, corresponding to urls.py, and rendering a web page in templates allows you to input what you want to see into the web page.

models.py

It’s related to database operations, so when you’re storing or reading data, you don’t have to use it when you’re not using the database.

forms.py

Forms, user input data submission in the browser, data validation and input box generation and other work.

Templates folder

The functions in views.py render the Html templates in templates to create a dynamic web page. You can use caching to speed things up, of course. It’s a shame not to use such a good thing!

admin.py

Background, this is can use very little code can achieve the magic of background management east east

settings.py

Django Settings, configuration files, such as DEBUG switches, static file locations, etc.

conclusion

Anyway, Django has a lot of features, including DRF and other frameworks, to learn more about