상세 컨텐츠

본문 제목

Relationship between URLS and VIEWS

Django

by BenzhaminKim 2020. 10. 29. 16:51

본문

I'm going to explain how the url works with views.py

 

I put the angle bracket<> in the path as '<shortcode>'.

If I put http://localhost:8000/view1/sss to URL, 'sss' value is going to be a parameter from kirr_redirect_view function as a second parameter (shortcode).

 

urls to views

If I put <sss> like below,

    path('view1/<sss>',kirr_redirect_view),
def kirr_redirect_view(request,sss=None, *args, **kwargs):
    print(args)
    print(kwargs)
    print(sss)
    return HttpResponse("hello")

then the second parameter has to be same.

 

The below is the flow from Request to View.

'Django' 카테고리의 다른 글

Django with Docker  (0) 2021.01.15
Set Global Variable using settings.py  (0) 2020.10.29
Django URL with View  (0) 2020.10.29
Django Architecture  (0) 2020.10.29

관련글 더보기

댓글 영역