Файлы в медиа-каталоге, направляемые по динамической ссылке, блокируются

У меня есть динамическая ссылка, которую я объявил в django urls.py следующим образом

url(r'^(?P<user_name>[a-zA-Z0-9]+)',  views.dynamic_link,  name="user_details"),

Но все медиа файлы не отображаются на веб-страницах этой динамической ссылки, хотя url этих файлов правильные, в то время как все файлы в статической папке отображаются. файлы в статической папке были показаны.

Я вызвал медиафайл через

<img src="{% get_media_prefix %}{{list.picture}}" alt="this is alt {{img}}">

Это пример ссылки url медиа и статического файла в коде веб-страницы

/static/css/bootstrap.css

/media/images/byron_cream.jpg

Когда я пытался просмотреть изображения, css и т.д. из моей статической папки непосредственно из браузера, браузер отображал изображения, css и т.д. но делая то же самое с медиа файлами, браузер не показывал их, а посылал страницу, чтобы показать, что url не существует (которую я создал для несуществующего url). я создал для несуществующего url).

При дальнейшем тестировании

  1. I saw that the url of the media file was passing through the def dynamic_link function unlike that of the static files
  2. In other to ensure that a url which exist in my database is what is being called I have written my views function to check that any url which is passed thrugh the dynamic link is available in the database. This explains why it was being blocked in the dynamic_link functionand sending the page that the url does not exist
  3. When i commented the dynamic link (i.e. the dynamic_link was not functional) the image coming from the media directory was showing up directly inside the browser like the way the static file were showing up

Мой вопрос заключается в следующем

  1. Why is the media file not showing up in the webpage of the dynamic link but the static file is showing up inside the same webpage?
  2. Why is the media file routing through the dynamic link and the static file is not routed through the dynamic link even when I check it through the web browser
Вернуться на верх