Hard-coded static asset URL in template

Hard-coding static asset urls is brittle because the place the files are stored depends on the `STATICFILES_STORAGE` used - so if in prod the storage backend uploads to S3 or even renames the file then this hard-coded URL will break.

Using "{% static ... %}" solves that as it knows exactly where the files are stored.

If we spot this issue in your GitHub pull request we give this advice:

django-doctorbotsuggested changes just now
template.html
+
<img src="/static/logo.png" />
Suggested changes
-
<img src="/static/logo.png" />
+
{% load static %}
+
<img src="{% static 'logo.png' %}" />
Commit suggestion

Hard-coding static asset urls is brittle because the place the files are stored depends on the `STATICFILES_STORAGE` used - so if in prod the storage backend uploads to S3 or even renames the file then this hard-coded URL will break.

Using "{% static ... %}" solves that as it knows exactly where the files are stored.

Read more
Update template.html
We're your Django code review copilot. Get code improvements right in your pull request with our GitHub code review bot.

Configuring this check

Django Doctor will run this check by default. No configuration is needed but the check can be turned on/off using check code hard-coded-static-url in your pyproject.toml file.

Read more about configuring Django Doctor.