in Technology by
How to configure static files in Django?

1 Answer

0 votes
by

Ensure that django.contrib.staticfiles is added to your INSTALLED_APPS

In your settings file. define STATIC_URL for ex.

STATIC_URL = '/static/'

In your Django templates, use the static template tag to create the URL for the given relative path using the configured STATICFILES_STORAGE.

{% load static %}
<img src="{% static 'my_sample/abcxy.jpg' %}" alt="ABC image">

Store your static files in a folder called static in your app. For example my_sample/static/my_sample/abcxy.jpg

Related questions

0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 5, 2022 in Education by JackTerrance
0 votes
    I have deployed a Django project on Ubuntu 16.04 with Nginx and Gunicorn. I have gotten everything, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    I have a very long forms.py and I'd like to split it to smaller parts with as few as possible ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    Can a static library (.a) contain resources like images, sound files etc?...
asked Nov 10, 2020 in Technology by JackTerrance
0 votes
    Since I got multiple classes and utility-functions I reuse on a regular basis, I started to create a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    Since I got multiple classes and utility-functions I reuse on a regular basis, I started to create a ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    How to configure inclusions & exclusions in Artifacts Archival?...
asked Sep 14, 2021 in Technology by JackTerrance
0 votes
    I have a scenario that I want to implement in Laravel. I have already implemented this kind of approach ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    I have a scenario that I want to implement in Laravel. I have already implemented this kind of approach ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have a scenario that I want to implement in Laravel. I have already implemented this kind of approach ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I am wanting to understand this Karaf JPA example. When I follow the instructions to add features and run ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 8, 2022 in Education by JackTerrance
0 votes
    Every time I try to run a small application that uses a Derby DB I get this error message: ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    Every time I try to run a small application that uses a Derby DB I get this error message: ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 23, 2022 in Education by JackTerrance
0 votes
    I have been able to define multiple aspects (one is @Before and another is @Around) using Spring AOP ( ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 18, 2022 in Education by JackTerrance
...