FBV implementation to create the dashboard view, changed previous project method

parent f89605c9
from django.http import HttpResponse from django.shortcuts import render, redirect
from django.views.generic import DetailView, CreateView, UpdateView, ListView
from .models import Department, WidgetUser from .models import Department, WidgetUser
# dashboard view from .models # dashboard view from .models
def dashboardIndex(request): def dashboard_view(request):
users = WidgetUser.objects.all() users = WidgetUser.objects.all()
departments = Department.objects.all() return render(request, 'dashboard/dashboard.html', {'users': users})
dashboard_output = "Welcome to Widget! <br><br> WIDGET USERS: <br><br>"
for user in users:
username = str(user)
home_department = str(user.department)
dashboard_output = dashboard_output + username + ": " + home_department + "<br>"
return HttpResponse(dashboard_output) class WidgetUserDetailView(DetailView):
model = WidgetUser
template_name = "widgetuser-details.html"
......
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