I want to know how to get the absolute URL of my static file directly in my template in Django?
Now in my template:
<link rel="stylesheet" href="{% static "css/bootstrap.min.css" %}">
return
<link rel="stylesheet" href="/static/css/bootstrap.min.css">
How can I get to dev:
<link rel="stylesheet" href="http://127.0.0.1:8000/static/css/bootstrap.min.css">
in production
<link rel="stylesheet" href="https://mycompany.com/static/css/bootstrap.min.css">
django django-templates
Guillaume vincent
source share