Reputation: 25554
I'm developing a website with Django. This is correct or I should avoid doing it in this way?
<img src="http://{{ request.META.HTTP_HOST }}/media/assets/img/bike.gif">
I'm doing this because I have internationalization in this project and I translate also the url patterns.
There are other strategies to get the root url?
Best Regards,
Upvotes: 0
Views: 969
Reputation: 4121
It seems that since you are using the HTTP_HOST that user's browser sent, you can simply write it as
<img src="/media/assets/img/bike.gif">
and get the same result.
Upvotes: 3