Silver Library (Archived)
Django - class based view, ListView 본문
반응형
,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.
Note for attribution:
* 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 |