user1757703
user1757703

Reputation: 3015

Django protocol relative URLs when serving static files

When ever I add a add a static file using the {% static '...' %} tag the URL output is an absolute url rather than a protocol relative URL. How do I get protocol relative URLs in Django? Do I have to hard code it in?

I get this using the static tag: <script src="http://s.cdn.example.com/js/jquery-1.11.1.min.js"></script> where I want <script src="//s.cdn.example.com/js/jquery-1.11.1.min.js"></script>.

Upvotes: 0

Views: 294

Answers (1)

user1757703
user1757703

Reputation: 3015

Set STATIC_URL when using a subdomain to serve your static files to the protocol relative url like so STATIC_URL = '//s.cdn.example.com/'.

Upvotes: 1

Related Questions