[Answered ]-Referencing static files in Django

1๐Ÿ‘

โœ…

As described in the docs, assuming your filepath is BASE_DIR/static/sub_dir/example.pdf you can reference it like this:

<li class="ftco-animate">
    <a href="{% static 'sub_dir/example.pdf' %}" data-toggle="tooltip" data-placement="top" title="Facebook">
        <span class="ion-logo-facebook"></span>
    </a>
</li>

It is good practice to place your static files in a sub-directory named same as your app name. That way, it will be much easier to reference the files from different apps later on. That is why the example in the docs says {% static 'my_app/example.jpg' %}.

Also please make sure you go through the documentations and follow all the steps mentioned there.

๐Ÿ‘คSakib Hasan

Leave a comment