Commit 6551c896 authored by Joseph Izon's avatar Joseph Izon 💀

convert index view from FBV to CBV

parent 6fc1d708
No preview for this file type
......@@ -3,10 +3,11 @@ from django.conf.urls.static import static
from django.conf import settings
from . import views
from .views import IndexView
app_name = "homepages"
urlpatterns = [
path('', views.index, name='index'),
path('', IndexView.as_view(), name='index'),
# homepage/id_num
path("users/<int:id_num>/details", views.detail, name="detail"),
......
from urllib import response
from django.http import HttpResponse, Http404
from django.shortcuts import render, redirect
from django.views import View
from homepage.models import WidgetUser
from .forms import WidgetUserForm
# Create your views here.
def index(request):
"""def index(request):
user_list = WidgetUser.objects.order_by("last_name")
......@@ -15,6 +17,14 @@ def index(request):
}
return render(request, "homepage/index.html", context)
"""
class IndexView(View):
def get(self, request):
user_list = WidgetUser.objects.order_by("last_name")
context = {
"user_list": user_list,
}
return render(request, "homepage/index.html", context)
def detail (request, id_num):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment