[PYTHON] Let's introduce the library currently used by engineers with about 3 years of experience in Django

This article is the 10th day article of Django Advent Calender 2016.

Hello! I've been an engineer for about 3 years since I started using Django in my current job. This time, I would like to introduce the Django-related library that I am currently using, which also serves as a means of organizing my own knowledge.

Static file delivery

django-storages https://pypi.python.org/pypi/django-storages

A library for delivering static files on a CDN such as Amazon S3. A fork version called django-storages-redux was born because it wasn't compatible with Python3, but now it supports up to the latest 3.5. doing. Recently, whitenoise seems to be popular, and I'm thinking of switching if it's okay to try it.

django-compressor https://pypi.python.org/pypi/django_compressor/2.1

It is a library that combines multiple css and js files into one. There is also a function that embeds the contents inline and reduces the amount of data transfer by looking at line breaks and comments. It can also be combined with compilers such as altJS and Sass (SCSS).

easy-thumbnails https://pypi.python.org/pypi/easy-thumbnails/2.3

It is a library that generates so-called "thumbnail images". If the image that is the source of the thumbnail image is deleted, only the thumbnail image will remain as garbage, so you need to delete it regularly with the thumbnail_cleanup command.

Search

django-haystack https://pypi.python.org/pypi/django-haystack/2.5.1 I use it to do location information in Elasticsearch. When using location information, you can only search in the environment where libgeoip is installed.

Add commands to make development work convenient & simplify code of frequently written patterns

django-extensions https://pypi.python.org/pypi/django-extensions/1.7.5

It's a library that makes Django's features even more powerful, with the feeling that it's within reach. I especially like the following commands.

--runserver_plus command --Code can be executed on any line of the stack trace when an error occurs. --shell_plus command --The shell is started with frequently used import statements such as the model class and from django.conf import settings pre-executed.

django-formtools https://pypi.python.org/pypi/django-formtools/1.0

It is a library to realize the movement of "input" β†’ "confirmation" β†’ "send" that is often found in inquiry forms. Originally built into Django itself, it's now independent from 1.8.

django-model-utils https://pypi.python.org/pypi/django-model-utils/2.6

It is a library that allows you to concisely write patterns that are often used in model design. StatusField or [Choices](http://django-model-utils.readthedocs.io/en/ The latest / utilities.html # choices) class is often used because it's a cleaner way to write a field like "status" where you can only enter a predetermined value, rather than passing a tuple to the choices attribute normally. I will.

django-braces https://pypi.python.org/pypi/django-braces

A library of mixed-in classes of Class-based views. If you read the Documents carefully before you start development, it will be easier for you to proceed. For LoginRequiredMixin, LoginRequiredMixin is standard from Django 1.9. Now that you have / en / dev / topics / auth / default / # the-loginrequired-mixin), you should use the standard.

django-debug-toolbar https://pypi.python.org/pypi/django-debug-toolbar/1.6

A library that displays a debugging toolbar on the right side of the browser screen. It is useful to check the output contents of the log and the query thrown to the DB. There is also a handy command called debugsqlshell that will parse the queries that are thrown by model operations from the shell.

django-haystack-panel https://pypi.python.org/pypi/django-haystack-panel/0.2.1

An extension of django-debug-toolbar that parses queries thrown from django-haystack.

REST API djangorestframework https://pypi.python.org/pypi/djangorestframework/3.5.3

A standard library for creating services that provide REST APIs in Django. It's quite sophisticated, so depending on what you want to make, django-braces' JSONResponseMixin, JsonRequestResponseMixin, AjaxResponseMixin You should use it.

cache

django-fancy-cache https://pypi.python.org/pypi/django-fancy-cache

A library for things like "clear a specific page cache when this data is updated". (The standard page cache can't do that unexpectedly ...)

Security

django-axes https://pypi.python.org/pypi/django-axes

It is a library that freezes the login screen for a while if login fails a certain number of times. It is introduced as a countermeasure against bots trying to steal accounts with brute force (or reverse brute force). Since logs are spit out at the WARN level when frozen, it is a policy to notify by e-mail or Slack and block IP addresses that persistently retry with a firewall.

django-password-validation https://pypi.python.org/pypi/django-password-validation

You can force a somewhat complicated password when registering or updating a password. [Password validation] introduced from Django 1.9 This library backports (https://docs.djangoproject.com/en/dev/topics/auth/passwords/#password-validation) to 1.8 or earlier. The service I'm working on now uses 1.8, so I introduced it.

Other helpful sites

Read the Django project template cookiecutter-django requirements and below. recommend to. [^ 1] https://github.com/pydanny/cookiecutter-django

[^ 1]: By the way, cookiecutter-django is [introduced] by @aki_yok on the 5th day (http://akiyoko.hatenablog.jp/entry/2016/12/05/023834) "Two Scoops of Django" : Best Practices for Django 1.8 ”is also a recommended template.

Recommended Posts

Let's introduce the library currently used by engineers with about 3 years of experience in Django
Sort in Python. Next, let's think about the algorithm.
Understand in 10 minutes Selenium
Selenium running in 15 minutes
About __all__ in python
Let's introduce the library currently used by engineers with about 3 years of experience in Django
Let's use def in python
Think about architecture in python
Let's find pi in Python
About "for _ in range ():" in python
Start in 5 minutes GIMP Python-Fu
Let's prove the addition theorem of trigonometric functions by replacing the function with a function in SymPy (β‰  substitution)
The meaning of ".object" in Django
Setting to debug test by entering the contents of the library with pytest
The story of using mysqlclient because PyMySQL cannot be used with Django 2.2
Django ~ Let's display it in the browser ~
Let's claim the possibility of pyenv-virtualenv in 2021
The advantages and disadvantages of Django that people with one year of experience think
Understand the images of various matrix operations used in Keras (Tensorflow) with examples
Fix the argument of the function used in map
[Note] About the role of underscore "_" in Python
About the behavior of Model.get_or_create () of peewee in Python
The story of viewing media files in Django
Search by the value of the instance in the list
[Django] Let's try to clarify the part of Django that was somehow through in the test
I used Python to find out about the role choices of the 51 "Yachts" in the world.
A story about trying to introduce Linter in the middle of a Python (Flask) project