본문 바로가기

Python_WEB/Try_Django

[Django]Include the Navbar

반응형

CodingEntrepreneurs Django 강의 정리

include>

1. 다른 URLconf모듈로 전체 Python가져오기 경로를 사용

가이드

 

base.html>

<!doctype html>
<html lang="en">

<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
        integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">

    <title>{% block head_title %} Replace this value {% endblock %} CFE</title>
</head>

<body>
    {% include 'navbar.html' %}

    <div class="container">
        <div class="row">
            <div class="col-6 mx-auto">
                <!-- <h1>{{ title }}</h1> -->
                {% block content %}
                <!-- Replace this value -->
                {% endblock %}
            </div>
        </div>
    </div>
    {% include 'js.html' %}
</body>

</html>

 

js.html>

<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"
    integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj"
    crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"
    integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
    crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"
    integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI"
    crossorigin="anonymous"></script>

 

navbar.html>

<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <a class="navbar-brand" href="/">Try Django</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
        aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item">
                <a class="nav-link" href="/">Home</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="/blog">Blog</a>
            </li>
        </ul>
        <form class="form-inline my-2 my-lg-0">
            <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
            <button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
        </form>
    </div>
</nav>

 

반응형

'Python_WEB > Try_Django' 카테고리의 다른 글

[Django]Publish Date, Timestamp & Updated  (0) 2020.06.21
[Django]Include with Arguments  (0) 2020.06.21
[Django]Include the Navbar  (0) 2020.06.21
[Django]Blog Post Navigation  (0) 2020.06.21
[Django]Delete and Confirm  (0) 2020.06.21
[Django]Better Validation on Update Views  (0) 2020.06.21