0

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,

4

1 回答 1

3

似乎由于您使用的是用户浏览器发送的 HTTP_HOST,您可以简单地将其写为

<img src="/media/assets/img/bike.gif">

并得到相同的结果。

于 2013-05-10T08:46:31.397 回答