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

parent 126cd0f7
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 .models import WidgetUser, Department
def index(request):
text_in_http = "Welcome to Widget! <br> <br> WIDGET USERS: <br> <ul>"
for user in WidgetUser.objects.all():
text_in_http += "<li>{}, {} {} : {}</li>".format(user.last_name, user.first_name,
user.middle_name, user.department
)
text_in_http += "</ul>"
html_string = '<html><body>{}</body></html>'.format(text_in_http)
def dashboard_view(request):
return render(request, 'dashboard/dashboard.html',{'nickname': 'Dani'})
class WidgetUserView(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'
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