In Django, when I use:
{{ request.build_absolute_uri }}{% static \"img/myimage.jpg\" %}
It produces: \'http://myurl.com//static/img/myimage
The build_absolute_uri
method builds an absolute uri for the current page. That means that if you're on e.g. 'http://myurl.com/login/', the resulted full url would be 'http://myurl.com/login//static/img/myimage.jpg'.
Instead, use request.get_host()
(optionally together with request.scheme
for the url scheme), or preferably, use the sites framework to set a template variable to the current site domain. The get_host()
method has some issues regarding proxies.
The get_host()
method will return the current domain without a path appended.