inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

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

get_success_url 함수 그리고 리팩토링

user와 request.user

479

cyjyj5

작성한 질문수 1

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 %}

python docker django

답변 0

강의에 나왔던 js 파일이 깃허브에 없습니다

1

69

1

모바일 디버깅, 반응형 레이아웃 4분48초 질문

0

48

1

decorator 관련질문입니다.

0

53

1

PasswordChangeView

0

96

2

로그아웃뷰 작동 관련 (2025년 3월)

1

130

1

실행에러질문

0

149

1

@login_required 데코레이터 사용시 리다이렉트는 어디서 참조하여 설정을 하는걸까요?

0

112

1

CacheBackend 관련 에러

0

174

1

21강 CreateView를 통한 회원가입 구현 질문

0

323

1

53강 disallowedhost

0

338

2

502 Bad Gateway

0

471

0

mariadb 접근권한 오류

0

536

1

logout 후 빈 화면으로 이동합니다 ㅠㅠ

0

453

2

로그아웃 후 빈 화면으로 이동

0

325

1

서버 운영 관련 질문 드립니다.(Unable to retirve...)

0

232

1

static/base.css파일을 인식을 못합니다

0

375

1

안녕하세요 19강 디버깅 설정 질문있습니다.

0

289

1

프로필 update편 질문있습니다.

0

375

1

수업질문

0

390

1

COOP error

0

525

1

61강 Dockerfile error

0

594

1

static안에 base.css 에서 정의한 클래스가 적용되지 않습니다.

0

488

1

static 파일 중 jpg 파일만 로드 불가

0

415

1

58강 static 파일 적용 안됨

0

543

1