Python/Django
[Django] Django .html .css 분리 방법 (by. Django Template)
yubi5050
2022. 6. 3. 17:33
👉 1. CSS 분리
1) settings.py 에 아래 문구 추가
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)
2) css 파일 작성 : css/init_page.css 파일을 작성하였다.
.init_wrapper{
width:100%;
display:flex;
}
.init_container{
text-align:center;
}
3) init.html 에 아래 문구 추가
{% load static %}
<link rel="stylesheet" href="{% static 'css/init_page.css' %}" type="text/css">
👉 2. HTML 분리 (include 문법)
1) HTML 파일 작성 : join.html, login.html, message.html
2) 원하는 곳에 include 문법 작성
{% include 'users/message.html' %}