Commit 511e4e76 authored by Anya Habana's avatar Anya Habana

Created and rendered template for homepage/

parent d11a708a
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget Users{% endblock %}
{% block styles %}
<link rel="stylesheet" href="{% static 'css/styles.css' %}">
{% endblock %}
{% block content %}
<h1 class="homepage-heading">Welcome to Widget!</h1>
<h2 class="homepage-subheading">Widget Users:</h2>
{% if user_list %}
<ul>
{% for user in user_list %}
<li><a href="/users/{{ user.id }}/details/"></a>{{ forloop.counter }}. {{ user.last_name }}, {{ user.first_name }} {{ user.middle_name }}</li>
{% endfor %}
</ul>
{% else %}
<p> There are no widget users currently. </p>
{% endif %}
{% endblock %}
from django.shortcuts import render
from django.http import HttpResponse
from django.template import loader
from .models import WidgetUser
def index(request):
formatted_widget_users = "WIDGET USERS:<br>"
user_list = WidgetUser.objects.order_by("last_name")
template = loader.get_template("users/index.html")
context = {
"user_list": user_list,
}
for user in WidgetUser.objects.all():
formatted_widget_users += user.getWidgetUser()
return HttpResponse(formatted_widget_users)
\ No newline at end of file
return HttpResponse(template.render(context, request))
\ No newline at end of file
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