Django CBA Handling keywords arguments and Request

Handling kwargs keywords arguments in DJango Class Base Views

Django is fast enough to construct base website in few minutes. But for Django Begginer when it comes to want to know how django works… it can be frustrating Because Django functions are deep hidden.

Today is about Django’s Class Based View and how keyword arguments, request passed from one to other.


  • Class Based View has many methods and You have to know view is eventually always function.
    Django process a request. urlconf regexp will be passed to the view *args and **kwargs.

  • CBA is less obvious what view function actually does and where the view functions is. Because this view function is hiddden deep within Django. CBV has as_view function and this function will return the actual view function.

Step2 Keyword Arguments Handlings

  • when you write keyword arguments in like MyView.as_view(someargs=somevalue), this keywords will be passed to CBV instance, and finally calls dispatch() function. And this keyword are referred to as initkwargs

  • request, *args, **kwargs are passed to dispatch() and dispatch() look at the request and calls get(), post(), delete() etc. depending on request type and again pass the arguments.

  • Simple and Beautile Class Based View : Django Vanila Views

참고 출처 :

© 2017. by yunsu

Powered by dolphin