What happens when the server starts as soon as the request arrives?

I do class hackers in Django. And I invoke my changes with settings.py, as I believe this is done first.

However, I just came across a situation where this does not work for me. So, is there any place after settings.py that I can guarantee will always be executed by the server before it starts to process any requests?

+3
source share
4 answers

You should not put code in settings.pythat requires importing anything from any part of Django. Since many parts of Django require settings to be available, this is likely to cause cyclic import issues.

ROOT_URLCONF (urls.py) , Python , , - .

( , ), models.py __init__.py.

. .

+6

, " ", . /manage.py?

:

, manage.py Django . manage.py - django-admin.py, django-admin.py:

sys.path. DJANGO_SETTINGS_MODULE , settings.py .

- , settings.py, , .

0
0

- django, django, INSTALLED_APPS. __init__.py, models.py . , , .

-1
source

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


All Articles