Efficient import of modules in Django views

I was wondering: how do people handle the import of a large number of commonly used modules in django views? And what is the best way to do this effectively?

For example, I have some species, for example,

admin_views.py
search_views.py
.
.

and from what I saw, each of them should use HttpResponse or other similar commonly used modules. Moreover, some of them need things like BeautifulSoup, while others need other things (md5, auth, etc.).

What I did when I started the project was to create include_all.py, which contained most of my general imports, and then add these specific things in the view itself. So I had something like:

admin_views.py

from include_all import *
... 
[list of specific module imports for admin]
...

search_views.py

from include_all import *
... 
[list of specific module imports for search]
...

include_all misc -, - , .

? , python (django?) / , , , ? - ?

- ?

!

+3
3

Python , ( reload, ): import sys.modules[themodulename], . Django , .

- from ... import * ( , , ..) " ", , (, , , , , " , " - , , - ).

+6

, __init__.py.

0

Django is not CGI (or PHP). Your application is one (or several) long-running Python process. No matter how long it takes to start, each HTTP request will simply call your (already loaded) view functions.

0
source

Source: https://habr.com/ru/post/1712431/