Da es nicht eindeutig war, wie CSS zu reflektieren ist, werde ich es beschreiben.
【Umgebung】 os python3.7.3 Django3.0.5
Anwendungsname: sns
【Dateiorganisation】 sns | - snsproject | | - setting.py | | - urls.py | - snsapp | | - urls.py | | - views.py | - templates | | - sns | | | - index.html | - static | | - css | | | - style.css |manage.py
Ich werde es sofort umsetzen.
settings.py
・ ・ ・
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'sns', #Nachtrag
]
・ ・ ・
TEMPLATES = [
{
'DIRS': [
os.path.join(BASE_DIR, 'templates'), #Nachtrag
],
],
},
},
]
・ ・ ・
STATIC_URL = '/static/'
STATICFILES_DIRS = (
[
os.path.join(BASE_DIR, "static"), #Nachtrag
]
)
Bearbeiten Sie als Nächstes templates / index.html.
index.html
{% load static %}
<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>sns</title>
<link href="{% static 'css/stylesheet.css' %}" rel="stylesheet">
</head>
<body>
</body>
</html>
Das CSS wird jetzt wiedergegeben.
Recommended Posts