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> <p>
<h2>WIDGET USERS:</h2> <h2>WIDGET USERS:</h2>
{% if Departments %} {% if WidgetUser %}
<ol> <ol>
{% for department in Departments %} {% for widgetUser in WidgetUser %}
<li> <li>
<a href="/homepage/{{department.id_num}}/"> <a href="/homepage/{{department.id_num}}/">
{{department.widgetuser.last_name}}, {{widgetUser.last_name}},
{{department.widgetuser.first_name}} {{widgetUser.first_name}}
{{department.widgetuser.middle_name}} {{widgetUser.middle_name}}
</a> </a>
</li> </li>
{% endfor %} {% endfor %}
......
...@@ -4,5 +4,5 @@ from . import views ...@@ -4,5 +4,5 @@ from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='index') 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.http import HttpResponse
#from django.template import loader
from django.shortcuts import render from django.shortcuts import render
from .models import Department
def index(request): def index(request):
#Departments = Department.objects.all() global WidgetUser
Departments = Department.objects.order_by("last_name")
#template = loader.get_tempate("widgetusers_orderedlist.html") widgetUser = WidgetUser.objects.order_by("last_name")
context = { context = {
"Departments": Departments "WidgetUser": widgetUser
} }
return render(request, "widgetusers_orderedlist.html", context) return render(request, "homepage/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})
# def detail(request, user_id): # def detail(request, user_id):
# try: # try:
...@@ -22,8 +18,5 @@ def index(request): ...@@ -22,8 +18,5 @@ def index(request):
# except Department.DoesNotExist: # except Department.DoesNotExist:
# raise Http404("User does not exist!") # raise Http404("User does not exist!")
# return render(request, "homepage/details.html", {"Departments": Department}) # 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