작성
·
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 %}
답변