FInch301
FInch301

Reputation: 21

I can't understand how to use correct static in django

I'm trying to display a picture whose address is saved in the Django models attribute. As I know you need to enter in the fieldurl({% static movie.img %}) but it doesen't works. If only use url({% static 'img/default-movie.png' %}) it works.

That is my query sets from django shell:

In [21]: Movie.objects.first().img
Out[21]: <ImageFieldFile: ../MovieApp/movies/static/img/1202296.jpg>

P.S (I should mentioned, that these fields are in for loop {% for movie in movies %} )

Upvotes: 0

Views: 112

Answers (1)

Chymdy
Chymdy

Reputation: 660

It is not a static resource. This should do

src={{movie.img.url}}

Upvotes: 1

Related Questions