
success_url 이 hello_world로 되어 있는데
우리의 profile을 수정하고 나서 완료가 됐으면 우리의 계정페이지로 가는게 자연스럽다
따라서 수정하기 위해서
success_url = reverse_lazy('accountapp:detail' 이렇게 수정할 것이다
하지만 이렇게 하면 적용이 되지 않는다.
왜냐하면 detail페이지는 accountapp 에서 url path를 보게 되면 detail 에서 pk라는 추가적인 data가 가야한다.
하지만 이렇게 단순히 detail로 지정하는것은 추가적인 데이터를 동적으로 보내줄 수 없다.
그래서 설정하고 싶다면 내부 method를 수정해줘야한다.

def get_success_url(self): return reverse_lazy('accountapp:detail', kwargs={'pk': self.object.user.pk})
라고 지정해야한다.
self.object 가 가리키는 것은 profile이다.
즉 profile의 user의 pk를 찾아서 detail에 넘겨주는 것이다.
이것을 UpdateView에도 적용시킨다.


계정을 수정하면 페이지로 복귀 성공
기존에 로그인 - 마이페이지 에서 로그아웃을 해도 edit 할 수 있는 오류가 발생했다.
<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 : 'NanumSquareB' ">
{{ target_user.profile.nickname }}
{% if target_user == 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 == user %}
<a href="{% url 'profileapp:create' %}">
<h2 style="font-family : 'NanumSquareB'">
Create Profile
</h2>
다음과 같이 수정하면 로그아웃을 하면 edit 이 사라지게 된다.
그리고 아무것도 설정하지 않은 사람은 "닉네임 미설정" 이라는 출력이 나오게끔 수정한다.

