3๐
I have similar problem (Django 1.10). Hierarchy:
myapp
...
myapp
...
blog
migrations
templates
...
static
blog
style.css
So if I add <link href="{% static 'blog/css/bootstrap.min.css' %}" rel="stylesheet">
(style.css
located in dir โblog/cssโ) all styles wonโt work.
BUT when I delete โcssโ: <link href="{% static 'blog/bootstrap.min.css' %}" rel="stylesheet">
(style.css
located in dir โblogโ) itโs ok.
May be it help you!
2๐
I think you need to add following to your URLs:
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
unless you work on Django server and it serves your static files.
According you the Django docs your app structure is OK.
When you will setup your prod and start serve static by Apache/Nginx/etc, than you will need to run collectstatic.
For now it donโt needed.
- [Answered ]-Django Bulk Model Deletion with Indices
- [Answered ]-Pythonic method for Django loop
- [Answered ]-Django Custom Client Login Page not Authenticating
- [Answered ]-Django form with bootstrap
0๐
My quick guess is that you are one level up. You have your static
directory nested under appname
. Try moving it up a level and accessing the resource directly in the browser (http://example.com/static/appname/css/bootstrap.min.css)
Iโve never done app specific resources, so if that is the goal, my apologies.
0๐
what if your static link starts with just appname
?
i.e., instead of
<link href="{% static 'static/appname/css/bootstrap.min.css' %}" rel="stylesheet">
please try
<link href="{% static 'appname/css/bootstrap.min.css' %}" rel="stylesheet">
AFAIK, the string in {% static %}
is the path to a static file inside the static folder.
I donโt have points enough to comment, so I leave my guess here.
- [Answered ]-Not able to open http://localhost:8000/ but opening in public ip ngnix Django
- [Answered ]-Deployment with Django and Uwsgi
-1๐
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
- [Answered ]-Getting AttributeError while registering my model to Django admin?
- [Answered ]-Django Slugfield removing articles ('the', 'a', 'an', 'that')
- [Answered ]-Django Model Admin with FileField cannot read file in save_model after reading file when validating
- [Answered ]-Django: How to register User to SimpleHistoryAdmin
- [Answered ]-External JS in Django apps best practice
-2๐
You need to put this line on the outside of HTML tags.
{% load static %}
I found the answer here: https://tutorial.djangogirls.org/en/css/.
- [Answered ]-One out of four radio buttons hidden
- [Answered ]-PyCharm console โ no module named
- [Answered ]-Manually enter a value in django model form
- [Answered ]-Pointing Django to Different Template Directory