Skip to content

Commit

Permalink
(중급편) 8강
Browse files Browse the repository at this point in the history
  • Loading branch information
jimin-kiim committed Jul 19, 2021
1 parent 60253c7 commit 2fcc7c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions AskdjangoBasic/askdjango/askdjango/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
# if form.is_valid():
# user = form.save()
# auth_login(request, user)
# return redirect('profile') # 회원가입 제대로 했으면 로그인 페이지
# next_url = request.GET.get('next') or 'profile'
# return redirect(next_url) # 회원가입 제대로 했으면 로그인 페이지
# else:
# form = SignupForm()
# return render(request, 'accounts/signup.html', {
# 'form': form,
# })


class SignupView(CreateView):
model = User
form_class = SignupForm
template_name = 'accounts/signup.html'

def get_success_url(self):
return resolve_url('profile')
next_url = self.request.GET.get('next') or 'profile'
return resolve_url(next_url)

def form_valid(self, form):
user = form.save()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ <h1>
<a href="{% url "profile" %}">{{ user }}</a>
<a href="{% url "logout" %}?next={{ request.path}}" onclick="return confirm('Are you sure?');">로그아웃</a><!--로그아웃 성공하면 원래 있던 곳(홈)으로 -->
{% else %}
<a href="{% url "signup" %}">회원가입</a>
<a href="{% url "signup" %}?next={{ request.path }}">회원가입</a>
<a href="{% url "login" %}?next={{ request.path }}">로그인</a><!--accounts에서는 네임스페이스 대개 지정하지 않는다.--><!--로그인 끝나면 원래 있던 패이지로-->
{% endif %}
<hr/>
Expand Down

0 comments on commit 2fcc7c8

Please sign in to comment.