인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

cyjyj5님의 프로필 이미지
cyjyj5

작성한 질문수

작정하고 장고! Django로 Pinterest 따라만들기 : 바닥부터 배포까지

get_success_url 함수 그리고 리팩토링

user와 request.user

작성

·

461

0

detail.html 코드에서 질문입니다.

로그인 한 상태에서 edit 링크를 보여주려고 {% if target_user == request.user %}를 입력하고,

Change Info 링크를 보여주기 위해 {% if target_user == user %} 라고 입력했는데....

똑같은 역할을 하는 것 같긴 한데, 위의 request.user와 user는 차이가 있을까요?

아니면 {% if target_user == user %} 에서 user 앞에 request라는 의미가 함축되어 있는 건가요?

 

<전체 코드>

{% extends 'base.html' %}

{% block content %}

  <div>
    <div style="text-align: center; max-width: 500px; margin: 4rem auto;">

      {% if target_user.profile %}
      <img src="{{target_user.profile.image.url}}" alt=""
           style="height: 12rem; width: 12rem; border-radius: 20rem; margin-bottom:2rem;">

      <h2 style="font-family: 'NanumSquareNeocBd';">
        {{target_user.profile.nickname}}
        {% if target_user == request.user %}
          <a href="{% url 'profileapp:update' pk=target_user.profile.pk %}">
            edit
          </a>
        {% endif %}
      </h2>
      <h5 style="margin-bottom: 3rem;">
        {{target_user.profile.message}}
      </h5>

      {% else %}
      {% if target_user == request.user %}
      <a href="{% url 'profileapp:create' %}">
        <h2 style="font-family: 'NanumSquareNeocBd'">
          Create Profile
        </h2>
      </a>
      {% else %}
      <h2>닉네임 미설정</h2>
      {% endif %}
      {% endif %}
      {% if target_user == user %}
      <a href="{% url 'accountapp:update' pk=user.pk %}">
        <p>
          Change Info
        </p>
      </a>
      <a href="{% url 'accountapp:delete' pk=user.pk %}">
        <p>
          Quit
        </p>
      </a>
      {% endif %}
    </div>
  </div>

{% endblock %}

답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
cyjyj5님의 프로필 이미지
cyjyj5

작성한 질문수

질문하기