Django - 북마크 만들기 5 (templates)

yunseul·2024년 6월 9일

Django

목록 보기
7/30
  • {% url %}
    • {% url %} 템플릿 태그는 URL 패턴에서 URL 문자열을 추출하는 역할

bookmark_list.html 템플릿 작성

### 위치 이동
cd /Users/user/test/django/project/web/bookmark

### templates 디렉토리 생성
mkdir -p templates/bookmark/

### 위치 이동
cd /Users/user/test/django/project/web/bookmark/templates/bookmark
vi bookmark_list.html

---

<!DOCTYPE html>
<html>
<head>
<tile>Django Bookmark List</title>
</head>

<body>

<div id="content">

        <h1>Bookmark List</h1>

        <ul>
                {% for bookmark in object_list %}
                        <li><a href="{% url 'detail' bookmark.id %}">{{ bookmark }}</a></li>
                {% endfor %}
        </ul>

</div>

</body>
</html>

profile
새로운 것을 시도하고 도전하는 것을 좋아하는 Engineer 입니다..

0개의 댓글