In that case, we do not keep such stylesheet in the static/ subdirectory of any particular app.
Instead we create a directory at the same level as and put project wide static resources in that directory. Create a directory called project_static at the same level as
We still do not need STATIC_ROOT and STATICFILES_DIRS. When we made a request for /static/other_style.css, Django knows that STATIC_URL is set to '/static/' which matches the first fragment of the url we provide and hence infers that we want it to serve a static file. Html of other_app changes to: You will find that the background of both pages is shown as red now.
To understand few other things about serving static files, we need one more app. So, it starts looking into static/ subdirectory of all the apps. Once we make this change, we will also have to change the html of homepage of other_app to include this file. It depends on what order you have the apps listed in INSTALLED_APPS.
Also make sure that you install Django inside your virtual environment as we don't want to pollute your system wide site packages. Create a directory called templates and add it to TEMPLATE_DIRS.
Whatever we saw till here is the default setting provided to us by Django. Let's create an app in which we will have a template and then we will write a static file, which will be a stylesheet, and will use that stylesheet in this template. We need a file for some_app where we will define the urls available on some_app. I created this templates directory on the same level as You should see that the background of this page becomes red. You will see that it's no more a 404 page and you will see the contents of your stylesheet at this url.
Just make sure to see the directory structure at the end of this section to get an idea of it, so that you will be comfortable in the next section. Next we need to start a Django project inside this virtualenv.
We will try everything inside a virtual environment. Make sure you are inside the virtualenv and have activated it.
Both these pages try to access a static file named So, we want to make h1 as italic across entire project.Django is still not aware about this file and will not serve it.Let's start with development when you have DEBUG = True.We will create a Django project from scratch so that we are fully aware about what file in what directory we are talking about.