Improvement: changed one view from homepage to CBV

Clean: further cleaning, removed unnecessary homepage imports
parent d3a2a64e
from email.policy import default
from django.db import models
# Create your models here.
......
......@@ -29,7 +29,7 @@
<br>
<br>
<a href="{% url 'homepage:index' %}"> Return to Homepage </a>
<a href="{% url 'homepage:WidgetUsersView' %}"> Return to Homepage </a>
</form>
{% endblock %}
\ No newline at end of file
from django.urls import path
from .views import WidgetUsersView
from . import views
app_name = "homepage"
urlpatterns = [
path('', views.index, name='index'),
path('', WidgetUsersView.as_view(), name='WidgetUsersView'),
path('users/add/newUser/', views.newUser, name='newUser'),
path('users/add/', views.createUser, name='createUser'),
path("users/<int:widgetuser_id>/details/", views.detail, name='details')
......
from homepage.forms import CreateUserForm
from .models import WidgetUser, Department
from django.http import HttpResponse, Http404
from django.http import Http404
from django.shortcuts import redirect, render
from django.views.generic import View
def index(request):
widgetUser = WidgetUser.objects.order_by("last_name")
context = {
"WidgetUser": widgetUser
}
return render(request, "homepage/widgetusers_orderedlist.html", context)
class WidgetUsersView(View):
def get(self, request):
widgetUser = WidgetUser.objects.order_by("last_name")
context = {
"WidgetUser": widgetUser
}
return render(request, "homepage/widgetusers_orderedlist.html", context)
def createUser(request):
department = Department.objects.all()
......
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