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'),
]

Conclusion

--

--

--

Interesting with Blockchain and Opensource Project my journal: https://www.perykun.xyz/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Integrate Smoothstate.js to WordPress Portfolio

Write a breakpoints class in responsive web design with javascript

React defaultProps Snippet

We can be found on Medium https://t.co/2zAIxNwil8

Free Currency Converter API In Javascript

Passing Props and States in React

TypeScript 4.0 — Breaking Changes

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
Feri Lukmansyah

Feri Lukmansyah

Interesting with Blockchain and Opensource Project my journal: https://www.perykun.xyz/

More from Medium

Python for Web Development

Build any Kind of Website using Django. . .

[Django] Django development notes (3) Static files Deployment

Add the slug field inside Django Model