Commit 20f64a0e authored by Anya Habana's avatar Anya Habana

Modified and rendered the users' details' template

parent af784cd4
......@@ -13,7 +13,7 @@
{% if user_list %}
<ol>
{% for user in user_list %}
<li><a href="/users/{{ user.id }}/details/">{{ user.last_name }}, {{ user.first_name }} {{ user.middle_name }}</a></li>
<li><a href="/homepage/users/{{ user.id }}/details/">{{ user.last_name }}, {{ user.first_name }} {{ user.middle_name }}</a></li>
{% endfor %}
</ol>
{% else %}
......
......@@ -8,17 +8,12 @@
{% endblock %}
{% block content %}
{% if user_list %}
{% for user in user_list %}
<h1 class="homepage-heading">{{ user.last_name }}, {{ user.first_name }} {{ user.middle_name }}</h1>
<ul>
<p>{{ user.id }}</p>
<p>{{ user.email }}</p>
<p>{{ user.department.dept_name }}</p>
<p>{{ user.department.home_unit }}</p>
</ul>
{% endfor %}
{% else %}
<p> There are no widget users currently. </p>
{% endif %}
<h1 class="homepage-heading">Widget User Details</h1>
<h2 class="homepage-subheading">{{ widgetuser.last_name }}, {{ widgetuser.first_name }} {{ widgetuser.middle_name }}</h2>
<ul>
<p>ID: {{ widgetuser.id }}</p>
<p>Email: {{ widgetuser.email }}</p>
<p>Department Name: {{ widgetuser.department.dept_name }}</p>
<p>Home Unit: {{ widgetuser.department.home_unit }}</p>
</ul>
{% endblock %}
from django.urls import path
from .views import index
from .views import WidgetUserDetailView, index
urlpatterns = [
path('', index, name='index'),
path('users/<int:pk>/details/', WidgetUserDetailView.as_view(), name='details'),
]
app_name = 'homepage'
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from django.views.generic.detail import DetailView
from .models import WidgetUser
user_list = WidgetUser.objects.order_by("last_name")
context = {
def index(request):
user_list = WidgetUser.objects.order_by("last_name")
context = {
"user_list": user_list,
}
def index(request):
template = loader.get_template("users/index.html")
return HttpResponse(template.render(context, request))
def details(request):
template = loader.get_template("users/users.html")
return HttpResponse(template.render(context, request))
\ No newline at end of file
class WidgetUserDetailView(DetailView):
model = WidgetUser
template_name = "users/users.html"
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