django-static-url¶
Added in 0.2.10 · Related issues · View source
What it does¶
Checks for asset URLs in <link>, <img>, <script>, and <source> elements that point at a
hardcoded static/ path instead of going through Django's {% static %} template tag.
Why is this bad?¶
Hardcoding /static couples templates to a single value of Django's STATIC_URL setting.
Projects that serve assets from a CDN, version assets with ManifestStaticFilesStorage, or
mount static files under a different prefix end up with broken URLs.
Example¶
Use instead:
{% load static %}
<link rel="stylesheet" href="{% static 'css/app.css' %}">
<img src="{% static 'img/logo.png' %}">