Commit 3694283e authored by AllenSkyy's avatar AllenSkyy

Added ListVies and Detail Vies for Homepage

parent 7ffd573d
<h1>WIDGET USERS: </h1>
{% for data in homepage %}
{{data.last_name}}, {{data.first_name}} {{data.middle_name}}: {{data.id_num}}, {{data.email}}, {{data.department.dept_name}}, {{data.department.home_unit}}<br>
{% endfor %}
{% block content %}
<ul>
<li>Complete Name: {{widgetuser.last_name}}, {{widgetuser.first_name}} {{widgetuser.middle_name}}</li>
<li>{{widgetuser.id_num}}</li>
<li>{{widgetuser.email}}</li>
<li>{{widgetuser.department.dept_name}}</li>
<li>{{widgetuser.department.home_unit}}</li>
{% load static %}
<li><img src="{% static 'homepage/pepe.png' %}" alt="image"></li>
</ul>
{% endblock content %}
{% extends 'base.html' %}
{% block content%}
<h1>Welcome to Widget!</h1>
<ul>
Widget Users:<br>
{% for widgetuser in object_list|dictsort:"last_name" %}
<body>
<a href="{% url 'homepage:widgetuser-detail' id_num=widgetuser.id_num %}">
{{forloop.counter}}. {{widgetuser.last_name}}, {{widgetuser.first_name}} {{widgetuser.middle_name}}<br>
</a>
</body>
{% endfor %}
</ul>
{% endblock content%}
from django.urls import path from django.urls import path
from .views import WidgetUserListView, WidgetUserDetailView
from .views import homepage
urlpatterns = [ urlpatterns = [
path('', homepage, name='homepage'), path('', WidgetUserListView.as_view(), name='widgetuser-list'),
path('users/<str:id_num>/details/', WidgetUserDetailView.as_view(), name='widgetuser-detail')
] ]
app_name = 'homepage' app_name = 'homepage'
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from .models import Department, WidgetUser from .models import Department, WidgetUser
from django.views.generic.detail import DetailView
from django.views.generic.list import ListView
class WidgetUserListView(ListView):
model = WidgetUser
def homepage(request): class WidgetUserDetailView(DetailView):
homepage_context = WidgetUser.objects.all() model = WidgetUser
context = {'homepage':homepage_context def get_object(self, queryset=None):
} return WidgetUser.objects.get(id_num=self.kwargs.get("id_num"))
return render(request, 'homepage.html', context)
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