1
1
12LiCaNtRoP122021-07-07 01:34:44
Django
12LiCaNtRoP12, 2021-07-07 01:34:44

What are these lines for?

Throughout my study of Django, with the tutorial on including media files, I have always seen that in the urls.py of the application of the project itself, these two lines are written:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += static(settings. STATIC_URL, document_root=settings.STATIC_ROOT)
I didn't find a sensible and understandable explanation anywhere, please explain.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nesterov, 2021-07-07
@12LiCaNtRoP12

In short, to form the correct URL for statics in the browser for a while while development is underway and the project is launched through the built-in server.
In the real world, this is done by the server (nginx/apache...)
Read more:
https://stackoverflow.com/questions/56352489/what-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question