7👍
In your settings.py
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
STATIC_URL = '/static/'
Then in your template file:
<link rel="stylesheet" href="{{ STATIC_URL }}css/home.css">
With the directory root structure that you have shown, I think the above setting should work. Have not tested it though. Let me know if it works.
5👍
set DEBUG=True
and see if it works .. this means, django will serve your static files, and not httpserver which in this case doesnt exist since you run the app locally.
- How to locally test Django's Sites Framework
- Django ModelChoiceField: how to iter through the instances in the template?
- Determine if Django is running under the development server
3👍
I had researched this problem for a full day. This will be okay:
DEBUG = True
ALLOWED_HOSTS = []
1👍
Django default BASE_DIR
will search static content for you. But in your case you changed the way before initial project. So for that in your case you have to change your BASE_DIR
like this .. then only static file will serve correctly
BASE_DIR = os.path.dirname(os.path.abspath(__file__) + '../../../')
Updated:
I didn’t see that comment. ! DEBUG = True
only for development and You set as False so will django use STATIC_ROOT = 'staticfiles'
to serve the static content on the production environment … Thank you
- Add dynamic field to django admin model form
- Django : Syncdb incorrectly warns that many-to-many field is stale
- Where is Pip3 Installing Modules?
- How do I make Django-Piston to include related child objects in the serialized output?
0👍
You don’t have to refer to STATIC_ROOT = 'staticfiles'
Just Like that:
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
0👍
I had the same issue in Django.
I added to my settings: STATIC_ROOT = ‘static/’
It was the only problem.