Python and Django Full Stack - Include Image and CSS References
In the previous blog post , we looked at template tags to render custom text. In this post, we will see how to refer to images and css files. The steps are the same as for template tags, except for the following differences: 1. Create a folder called static in the top level project folder. Inside the static directory, create two folders - i. images to store the pictures. (save any picture e.g. mypicture.jpg in this directory) ii. css to store the css file (e.g. mystyles.css) 2. Include this folder to the settings.py file, so Django knows where to find it. Note that the variable STATIC_URL comes pre-defined from versions 1.9 and up. Ensure there are no duplicate declarations of the variables. STATIC_URL = ' static/ ' STATICFILES_DIRS = [ ' static ', ] 3. Test if this works, by going ...