Fix: fixed bug where homepage would occasionally not display

Style: Edited views.py to arrange widget users by alphabetical order (last names)
parent 685da6a8
<p>
<h2>WIDGET USERS:</h2>
{% if Departments %}
{% if WidgetUser %}
<ol>
{% for department in Departments %}
{% for widgetUser in WidgetUser %}
<li>
<a href="/homepage/{{department.id_num}}/">
{{department.widgetuser.last_name}},
{{department.widgetuser.first_name}}
{{department.widgetuser.middle_name}}
{{widgetUser.last_name}},
{{widgetUser.first_name}}
{{widgetUser.middle_name}}
</a>
</li>
{% endfor %}
......
......@@ -4,5 +4,5 @@ from . import views
urlpatterns = [
path('', views.index, name='index')
path("<int:user_id>/", users/<user_id>/details/, name="detail")
]
\ No newline at end of file
from .models import Department
from .models import WidgetUser
from django.http import HttpResponse
#from django.template import loader
from django.shortcuts import render
from .models import Department
def index(request):
#Departments = Department.objects.all()
Departments = Department.objects.order_by("last_name")
#template = loader.get_tempate("widgetusers_orderedlist.html")
global WidgetUser
widgetUser = WidgetUser.objects.order_by("last_name")
context = {
"Departments": Departments
"WidgetUser": widgetUser
}
return render(request, "widgetusers_orderedlist.html", context)
#render HttpResponse(template.render(context, request))
#output = ", ".join([a.article_title for a in article_list])
#return render(request, 'widgetusers_listings.html', {'Departments': Departments})
return render(request, "homepage/widgetusers_orderedlist.html", context)
# def detail(request, user_id):
# try:
......@@ -22,8 +18,5 @@ def index(request):
# except Department.DoesNotExist:
# raise Http404("User does not exist!")
# return render(request, "homepage/details.html", {"Departments": Department})
return HttpResponse("This is Widget User # %s." % user_id)
# return HttpResponse("This is Widget User # %s." % user_id)
#def reaction(request, article_id)
#response = "These are the reactions to article #%s"
#return HttpsResponse(response % article_id)
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