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.

So in practice, do this


    # in index.html
    {% load static %}
    <img src="{% static 'logo.png' %}" />

Instead of this


    # in index.html
    <img src="/static/logo.png" />

Are you affected? Check with
pip install django-doctor
.

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.