오류 수정
accountapp의 urls.py에서 AccountUpdateView(UpdateView)와 AccountDeleteView(DeleteView)에
context_object_name = 'target_user'를 추가해준뒤
update.html과 delete.html에 user를 targer_user로 변경해준다.
27강 Authentication 인증시스템 구축
로그인 하지 않고 hello_world로 이동을 하고
2번 계정으로 로그인을 한뒤
1번 계정 삭제 페이지로 이동 할수있다.
이런 문제를 해결하기 위해 우선
def hello_world(request):
if request.user.is_authenticated:
if request.method == "POST":
temp = request.POST.get('hello_world_input')
new_hello_world = helloWorld()
new_hello_world.text = temp
new_hello_world.save()
return HttpResponseRedirect(reverse('accountapp:hello_world'))
else:
hello_world_list = helloWorld.objects.all()
return render(request, 'accountapp/hello_world.html', context={'hello_world_list': hello_world_list})
else:
return HttpResponseRedirect(reverse('accountapp:login'))
if request.user.is_authenticated:를 추가해서 is_authenticated하면 접속이 가능하고
그렇지 않으면 login.html로 보낸다.
'기타 > django' 카테고리의 다른 글
작정하고 장고 - profile 구현 (0) | 2023.05.20 |
---|---|
작정하고 장고 - decorator, superuser, media (0) | 2023.05.17 |
작정하고 장고 - UpdateView, DeleteView (0) | 2023.05.13 |
작정하고 장고 - DetailView를 활용한 개인 페이지 구현 (0) | 2023.05.11 |
작정하고 장고 - Bootstrap을 이용한 Form 디자인 정리 (0) | 2023.05.10 |
댓글