我遵循了书中的建议和其他解决方案,但它对我不起作用。我在做什么错了?
结果:
System check identified no issues (0 silenced).
July 16, 2018 - 20:37:29
Django version 2.0.5, using settings 'locallibrary.settings'
Starting development server at http://127.0.0.4:8000/
Quit the server with CONTROL-C.
[16/Jul/2018 20:56:46] "GET / HTTP/1.1" 200 1457
[16/Jul/2018 20:56:46] "GET /static/catalog/css/catalog.css HTTP/1.1" 404 1794
# structure
Development
manage.py
<Project>
( _init_.py, settings.py, urls.py, wsgi.py, rootstatic(to collect information) )
<Catalog>
(_init_.py, models.py, tests.py, views.py, static [catalog/css/catalog.css/]
#settings
DEBUG = True
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = '%s/rootstatic/' % (BASE_DIR)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['%s/templates/'% (PROJECT_DIR),],
'APP_DIRS': True,
},
]
# 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)
# template
<link href="{% static 'catalog/css/catalog.css' %}" rel="stylesheet">