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