-
Notifications
You must be signed in to change notification settings - Fork 2
Linking Static Files
Static file are handled a bit different in Django suppose that we need to link a css file to webpage normally we would do the following
<link rel="stylesheet" type="text/css" href="/main.css">
However, in Django this doesn't work we need to like previously create a different type of file system. Inside our blog project, we need to create a file structure called static
in that again have to create another directory with the name of our project and in our case blog, so our directory will have the following structure static/blog/
inside that, we add our css file.
after that we need to add this line to each page we make a line this is usually the first line in the page where we want to load the file
{% load static %}
this line of code enables us to load a static file. Now we can do the following.
<link rel="stylesheet" type="text/css" href="{% static 'blog/main.css' %}">
The word static
will create a hard link to the static folder and then link our css and now the page should have the css
- Django installation
- Django Project creation
- Package Directories
- Hello,World
- Setting up projects
- Routing
- Templating
- Django templating Engine syntax
- Passing variable to template
- Template inheritance
- Static file linking
- Admin page
- Django ORM
- Making DB
- ORM based queries
- Django Model set
- Use of ORM DB with Django