A
A
AlexBoss2019-06-18 12:16:51
Django
AlexBoss, 2019-06-18 12:16:51

How to use static file in Views in django?

How to use static file in Views in django?
In urls I registered + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT), added files to the folder.
I don’t quite understand how they can be used in Views, or rather, specify the path to them

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tema_sun, 2019-06-18
@tema_sun

from django.templatetags.static import static

url = static("path/to/file.jpg")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question