관리 메뉴

Silver Library (Archived)

Django - class based view, ListView 본문

Personal DB/Unclassified record

Django - class based view, ListView

Chesed Kim 2020. 12. 21. 14:46
반응형

,Jango has a method to convert class based view turn them as.view

 

Before

urlpatterns = [path("", room_views.all_rooms, name="home")]

 

Mid

urlpatterns = [path("", room_views.HomeView, name="home")]

# This will not work since HomeView is not recognised as Class.

 

After

urlpatterns = [path("", room_views.HomeView.as_view(), name="home")]

# By adding as_view() here, now it recognises HomeView as Class.

# Note: bracket (works as the symbol of a Class, function) made HomeView is visible as Class.

 

docs.djangoproject.com/en/3.1/ref/class-based-views/generic-display/#django.views.generic.list.ListView

 

Generic display views | Django documentation | Django

Django The web framework for perfectionists with deadlines. Overview Download Documentation News Community Code Issues About ♥ Donate

docs.djangoproject.com

Note for attribution:

https://ccbv.co.uk/

 

* Now Jango will be convenient.

'Personal DB > Unclassified record' 카테고리의 다른 글

Caution - Django, space  (0) 2020.12.24
Django - class based view + function based view  (0) 2020.12.21
Django get_page vs page  (0) 2020.12.21
Django - morning note  (0) 2020.12.15
Django - why I stuck? and solution  (0) 2020.12.14