인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

이준영님의 프로필 이미지
이준영

작성한 질문수

Do It! 장고+부트스트랩: 파이썬 웹개발의 정석

UserPassesTestMixin - 스태프에게만 포스트 작성 허용하기

form_valid 함수관련 몇가지 질문입니다.

작성

·

153

0

def form_valid(self, form):
current_user = self.request.user
if current_user.is_authenticated and (current_user.is_superuser or current_user.is_staff): #로그인을 했다면
form.instance.author = current_user
return super(PostCreate,self).form_valid(form)
else:
return redirect('/blog/')



1.

시크릿모드로 로그아웃 상태로 blog/create_post/로 들어갔을시

redirect('/blog/')로 blog쪽으로 돌아간다고 생각했는데 그냥

page not found만 뜹니다.


2.

redirect 의 인자로 '/blog/'가 오는 이유가 궁금합니다.


django_pro.url에서의 urlpattern인
path('blog/', include('blog.urls')) 인자처럼  

'blog/' 일거라고 생각했습니다.



답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
이준영님의 프로필 이미지
이준영

작성한 질문수

질문하기