Writing in the front

DRF has been written about for some time now, and has been functionally covered. Today, I will make a summary of the articles I have written these days, summarizing the technology as well as the work.

Project directory

The project directory is sorted in order of getting started. I hope each of these ten articles has been inspirational and helpful.

  • Introduction to the Django REST Framework
  • Django REST Framework login JWT
  • Django REST Framework login in action
  • Django REST Framework full-text search in action
  • Django REST Framework code style in real life
  • Django REST Framework documentation and logging
  • Django REST Framework exception handling
  • Django REST Framework limits traffic
  • Django REST Framework deployment in action
  • Django REST Framework Docker deployment in action

Actual combat share

See Github for details on the repository.

1. Technology selection

There are many Python Web frameworks, among which Django, Flask and Tornado are popular. With the growing development of the Python community, many excellent Web frameworks have emerged in the past two years. For details, please refer to my Python Asynchronous framework.

The advantages of Django, which I mentioned in my getting Started article, are that it has a rich ecosystem and comprehensive documentation. In fact, flasks also have this advantage, but flasks have their own advantages over Django. The bottom line is that Django is large and comprehensive, but it doesn’t have the ability to customize, and features only need to be configured according to official documents; Flask is small and elegant, and has rich support for third-party plug-ins, which need to be installed and configured by themselves.

The reason for choosing Django here is laziness. There is not too much time to do too much configuration, in line with the principle of taking the doctrine. Get started is a development, testing, iteration, on the line. A small release a day, an iteration a week, and a refactoring a month.

2. About databases

Django supports relational databases such as PostgreSQL, SQLite, MySQL, and Oracl. It is generally recommended to learn SQLite on your own, without spending too much time on the database. In other cases, choose based on the company’s technology.

Note that the default migrate command can only be used in a development environment. Production environments should use SQL to operate databases, both to avoid unforeseen risks and to better conform to development specifications.

The default migrate command can only be used in development environments.

The default migrate command can only be used in development environments.

The default migrate command can only be used in development environments.

3. About Django Admin

It is recommended to use the Admin page, as its use will greatly reduce the number of SQL submissions once the line is online. Extremely opener-friendly, but super administrator privileges can only be granted to a small number of people (it’s too powerful).

It is recommended to customize some command-line tools, such as scripts used in the development environment, scripts to initialize the database, export data, database differences, etc., so that your development efficiency can be multiplied

  • Django Admin Site
  • django-extensions

4. About code repositories

The project code for the entire DRF column has been put up on my Github. Welcome to STAR & FORK. Of course, if there is a bad writing is not correct, also welcome friends to testify, I will correct in time.

5. Other content about DRF

The knowledge here about DRF, and as an open framework, is basically sufficient. The ViewSet Serializer Filter can be used in different ways based on service requirements. Therefore, the ViewSet Serializer Filter is not described in detail here. Users should use the ViewSet Serializer Filter in the official document when required.

Of course, if you have a good feature point that you want me to continue to update, you are welcome to communicate.

6. Other techniques you might use

  • Task scheduling module developed by Celery Python.

    Work scenarios include scheduling of scheduled tasks and asynchronous tasks. We can use Djang-celery directly in Django, which encapsulates all the basic functions and operations of celery for us.

  • Redis is a high performance non-relational database based on memory.

    The service scenarios are as follows:

    • Cache Cache hot data to reduce data pressure
    • Queue and Celery realize message consumption monitoring and other functions
    • Distributed lock based on SETNX command atomic operation implementation to solve the problem of resource competition

Redis is fully open source and free, compliant with the BSD protocol, and is a flexible high-performance storage of key-value data structures that can be used as databases, caching and message queues.

Project recommend

Recommend a few popular open source Django projects for you to study

  • Use Django to build a blog quickly
  • Django-CMS
  • Jumpserver fortress machine