목록분류 전체보기 (373)
Silver Library (Archived)
*Imagine how html works. Or maybe how other languages work! class based view *context links to the template. (class)Listview may specialised in inheritance. (e.g. each action shall work accordingly) function based view may specialised in filtering stuff (e.g. aggregately run as intended)
,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..
Unlike other language does function like function(): in Django, this sounds like: {% if something.has_previous %} no (bracket), nor colon + except Exception stead, using Exception such like exception EmptyPage is better to use. => in order to return when a specific error occurred, targeting response to the error is better. (stead of Excepting all equally). *Why doing this? To prevent a troll use..
Jango does not allow to edit too much on the template (e.g. HTML) So, instead of the template: go to views.py, to add some custom logic. Patient...and remember: numeric code means...literally numeric outcome to see it. docs.djangoproject.com/en/3.1/ref/templates/builtins/ Built-in template tags and filters | Django documentation | Django Django The web framework for perfectionists with deadlines..