by Kunal Sir
Static-Files
Static files are files that don’t change when your application is running.
Static Files such as Images, CSS, or JS files are often loaded via a different app
in production websites to avoid loading multiple stuff from the same server. This
article revolves around, how you can set up the static app in Django and server
Static Files from the same.
Step 1:- Create a folder named with 'static' inside main project folder. It is exactly same as
creating 'templates' folder.
Step 2:- In that 'static' folder create 'image', ’CSS’, ’JS ’ folder to place image files,css file,etc.
Right click on “image” folder to open the file in export form and insert img-file in image folder.
Stop, Near, 1st Floor, Above Rupam Sweets/ Priyanka Collections Building Vikas Mitra Mandal Chowk Road,
Karve Nagar, Pune, Maharashtra 411052 , Mobile No.- 8888022204
by Kunal Sir
Stop, Near, 1st Floor, Above Rupam Sweets/ Priyanka Collections Building Vikas Mitra Mandal Chowk Road,
Karve Nagar, Pune, Maharashtra 411052 , Mobile No.- 8888022204
by Kunal Sir
Step 3:- Add static directory path to settings.py file, so that Django can aware of our images.
PROJNAME->PROJNAME->settings.py->STATICFILES_DIRS = ['static']
Step 4:- Load static files in the templates by using the below expression.
{% load static %}
"{% static '_____ file path ___________' %}"
Stop, Near, 1st Floor, Above Rupam Sweets/ Priyanka Collections Building Vikas Mitra Mandal Chowk Road,
Karve Nagar, Pune, Maharashtra 411052 , Mobile No.- 8888022204
by Kunal Sir
Stop, Near, 1st Floor, Above Rupam Sweets/ Priyanka Collections Building Vikas Mitra Mandal Chowk Road,
Karve Nagar, Pune, Maharashtra 411052 , Mobile No.- 8888022204