Commit 11ac5c79 authored by Elaiza Bolislis's avatar Elaiza Bolislis

Modified dashboard app's views.py, implementing FBV for the Dashboard page and...

Modified dashboard app's views.py, implementing FBV for the Dashboard page and CBV for the Per Widget User Details page, Add New Widget User page and Edit Widget User page.
parent 3e0eca39
from django.shortcuts import HttpResponse
from django.shortcuts import render
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from .models import WidgetUser
def index(request):
return_string = '<p>Welcome to Widget!</p>WIDGET USERS:<br>'
for user in WidgetUser.objects.all():
return_string += '{}: {}<br>'.format(user, user.department)
html_string = '<html><body>{}</body></html>'.format(return_string)
return HttpResponse(html_string)
def dashboard(request):
users = WidgetUser.objects.all()
return render(request, 'dashboard/dashboard.html', {'users': users})
class WidgetUserDetailView(DetailView):
model = WidgetUser
template_name = 'dashboard/widgetuser-details.html'
class WidgetUserCreateView(CreateView):
model = WidgetUser
fields = '__all__'
template_name = 'dashboard/widgetuser-add.html'
class WidgetUserUpdateView(UpdateView):
model = WidgetUser
fields = '__all__'
template_name = 'dashboard/widgetuser-edit.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