Commit efb32d62 authored by Chester Tan's avatar Chester Tan
parents 463341b3 aa2c4b30
<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 .views import homepage
from .views import WidgetUserListView, WidgetUserDetailView
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'
\ No newline at end of file
app_name = 'homepage'
from django.shortcuts import render
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):
homepage_context = WidgetUser.objects.all()
context = {'homepage':homepage_context
}
return render(request, 'homepage.html', context)
class WidgetUserDetailView(DetailView):
model = WidgetUser
def get_object(self, queryset=None):
return WidgetUser.objects.get(id_num=self.kwargs.get("id_num"))
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