7 Days Challenge to Push Your Hard Skill Using Django part 3: Which CBV or FBV should be used?

image from feldroy.com
from django.urls import reverse
from django.views.generic import ListView, DetailView, UpdateView
from .models import Tasting
class TasteListView(ListView):
model = Tasting
class TasteDetailView(DetailView):
model = Tasting
class TasteResultsView(TasteDetailView):
template_name = 'tastings/results.html'
class TasteUpdateView(UpdateView):
model = Tasting
from django.urls import path
from . import views
urlpatterns = [path(route='',view=views.TasteListView.as_view(), name='list'),path(route='<int:pk>/', view=views.TasteDetailView.as_view(), name='detail'),
path(route='<int:pk>/results/',view=views.TasteResultsView.as_view(), name='results'),
path(route='<int:pk>/update/',view=views.TasteUpdateView.as_view(),name='update')]
urlpatterns = [path('<int:pk>',DetailView.as_view(model=Tasting,template_name='tastings/detail.html'),name='detail'),path('<int:pk>/results/',DetailView.as_view(model=Tasting,template_name='tastings/results.html'),name='results'),
]

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store