class AccountDetailView(DetailView):
model = User
template_name='accountapp/detail.html'
어떤것을 만드는 것이 아니라 보여주기만 하기 때문에 어떤 model을 쓸지와 템플릿만 설정해주면 끝!
{% extends 'base.html' %}
{% block content %}
<div>
<div style="text-align: center; max-width: 500px; margin: 4rem auto;">
<p>
{{ user.date_joined }}
</p>
<h2 style="font-family: 'NanumSquareB'">
{{ user.username }}
</h2>
</div>
</div>
{% endblock %}
path('detail/<int:pk>', AccountDetailView.as_view(),name='detail'),
특정유저 정보를 위해 pk(User객체에서 알아서 생성)가 필요함
<a href="{% url 'accountapp:detail' pk=user.pk %}">
<span>MyPage</span>
</a>
pk를 넣어줘야하기 때문에 "{% url 'accountapp:detail' pk=user.pk %}" 하여 현재 user의 pk를 해당 pk에 넣어줌.
context_object_name = 'target_user'
detail.html user를 target_user로 변경
<h2 style="font-family: 'NanumSquareB'">
{{ target_user.username }}
</h2>
접속한 본인 user의 정보만 볼수있음. 다른 사람의 page를 들어가도 내 정보를 보여줌. 다른사람이 내 페이지에 들어오면 내 정보를 볼수있게 해줌