django 13 메인 페이지

Grace Goh·2022년 10월 10일
0

Django

목록 보기
14/32

html에서
{{ user.username }} 사용자 정보
{% %}를 사용하면 파이썬처럼 if문, for문 등을 쓸 수 있다.

home.html

<!-- templates/tweet/home.html -->
{% extends 'base.html' %}

{% block content %}
    <div class="container timeline-container">
        <div class="row">
            <!-- 왼쪽 컬럼 -->
            <div class="col-md-3">
                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">{{ user.username }}</h5>
                        <p class="card-text">{{ user.bio }}</p>

                    </div>
                </div>
            </div>
            <!-- 오른 쪽 컬럼-->
            <div class="col-md-7">
                <!-- 글을 작성 하는 곳 -->
                <div class="row mb-2">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-body">
                                <div class="media">
                                    <div class="media-body">
                                        <h5 class="mt-0">나의 이야기를 적어주세요</h5>
                                        <p>
                                        <form>
                                            <div class="form-group mb-2">
                                                <textarea class="form-control" style="resize: none" name='my-content'
                                                          id="my-content"></textarea>
                                            </div>
                                            <button type="submit" class="btn btn-primary" style="float:right;">작성하기
                                            </button>
                                        </form>
                                        </p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <hr>
                <!-- 작성 된 글이 나오는 곳 -->
                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-body">
                                <div class="media">
                                    <div class="media-body">
                                        <h5 class="mt-0">Media heading</h5>
                                        <p>Will you do the same for me? It's time to face the music I'm no longer your
                                            muse.
                                            Heard it's
                                            beautiful, be the judge and my girls gonna take a vote. I can feel a phoenix
                                            inside
                                            of me.
                                            Heaven is
                                            jealous of our love, angels are crying from up above. Yeah, you take me to
                                            utopia.</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="col-md-2"></div>
        </div>
    </div>
{% endblock %}

base.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{% block title %}{% endblock %} | spartaSNS</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js"
            integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf"
            crossorigin="anonymous"></script>
    <style>
        .title-center {
            text-align: center;
            margin-top: 50px;
        }

        .wrap {
            width: 400px;
            margin: 0 auto;
        }

        .form-area {
            margin-top: 25px;
        }

        .timeline-container {
            margin-top : 25px
        }
    </style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
    <div class="container">
        <a class="navbar-brand" href="/">SpartaSNS</a>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active">
                    <a class="nav-link" href="#"> 친구 <span class="sr-only"></span></a>
                </li>
            </ul>
        </div>
        <form class="form-inline my-2 my-lg-0">
            {% if not user.is_authenticated %} # 유저가 인증되어 있는지.
            <ul class="navbar-nav mr-auto">
                <li class="nav-item active">
                    <a class="nav-link" href="/sign-in"> Sign In <span class="sr-only"></span></a>
                </li>
                <li class="nav-item active">
                    <a class="nav-link" href="/sign-up"> Sign Up <span class="sr-only"></span></a>
                </li>
            </ul>
            {% else %}
                {{ user.username }} 님 반갑습니다!
            {% endif %}
        </form>
    </div>
</nav>
{% block content %}

{% endblock %}

</body>
</html>
profile
Español, Inglés, Coreano y Python

0개의 댓글