웹/Django

자주쓰는 HTML 태그

DEnor 2022. 12. 11. 17:33
반응형

1. 템플릿 상속

  • base.html
{% block tatle %}
    <title>타이틀 이름</title>
{% endblock %}

{% block extrahead %}
    <css,img 등 정적파일 로드> 
{% endblock %}
<body>
<상속할 내용>
{% block content %}
{% endblock %}
</body>
  • 상속받을.html
{% extends 'base.html' %}
{% block tatle %}
    <title>타이틀 이름</title>
{% endblock %}

{% block extrahead %}
    <css,img 등 정적파일 로드> 
{% endblock %}
<body>
{% block content %}
<템플릿 내용>
{% endblock %}
</body>

2.  기타 태그

name="<폼, url>"

  • 해당 요청이 일어나면 name값이 전달되어 url에 있는 해당 name을 실행한다
<div name="content">

 

 

{% url '<경로>' <URL전달값> %}

  • sns별칭을 가진 url에 들어있는 index를 호출하고 변수값으로 number를 넘겨준다
{% url 'sns:index' number %}

 

3. 각종 필터

date : 날짜출력값을 수정해주는 필터

{{ Blog.date|date:'Y-m-d H:i' }}

safe : auto-escape 되지 않는 태그를 escape하게 만드는 필터

{{ question.body | safe }}

 

 

참고

 

Django

The web framework for perfectionists with deadlines.

docs.djangoproject.com

 

Django

The web framework for perfectionists with deadlines.

docs.djangoproject.com

 

반응형