I have the next configuration:
urls.py
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^manager/', include('manager.urls')),
#Static pages
url(r'^index', TemplateView.as_view(template_name='index.html'), name='index'),
url(r'^', TemplateView.as_view(template_name='index.html'), name='index'),
url(r'^contact', TemplateView.as_view(template_name='contact.html'), name='contact'),
url(r'^services', TemplateView.as_view(template_name='services.html'), name='services'),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'pf.app.pfs',
]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "assets"),
#'/var/www/static/',
]
I executed the command:
python manage.py collectstatic
And the files are generated, also I added a css file with a single rule but and executed the command again.
But, in the momento to add it to my html file
<head>
{% load static %}
<link rel="stylesheet" href="{% static 'css/style.css' %}" />
</head>
in the html I get:
<link rel="stylesheet" href="/static/css/style.css">
And in the terminal:
"GET /static/css/style.css HTTP/1.1" 404 1766
What I have wrong in my static files configuration?