Updated views.py to accomodate widget user edit add and details

parent 126cd0f7
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView
from django.http import HttpResponse from django.http import HttpResponse
from .models import WidgetUser, Department from .models import WidgetUser, Department
def index(request): def dashboard_view(request):
text_in_http = "Welcome to Widget! <br> <br> WIDGET USERS: <br> <ul>" return render(request, 'dashboard/dashboard.html',{'nickname': 'Dani'})
for user in WidgetUser.objects.all():
text_in_http += "<li>{}, {} {} : {}</li>".format(user.last_name, user.first_name,
user.middle_name, user.department class WidgetUserView(DetailView):
) model = WidgetUser
text_in_http += "</ul>" template_name = 'dashboard/widgetuser-details.html'
html_string = '<html><body>{}</body></html>'.format(text_in_http)
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'
return HttpResponse(html_string)
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