Commit 2110edd2 authored by Ramon Angelo Enriquez's avatar Ramon Angelo Enriquez

Homepage Views are now functional in showing the database information in the required format

parent 389bc251
...@@ -10,7 +10,7 @@ class WidgetUser(models.Model): ...@@ -10,7 +10,7 @@ class WidgetUser(models.Model):
email = models.CharField(max_length=50, null=True) email = models.CharField(max_length=50, null=True)
def __str__(self): def __str__(self):
return self.first_name + " " + self.last_name return self.last_name + ", " + self.first_name
class Department(models.Model): class Department(models.Model):
......
...@@ -5,5 +5,18 @@ from homepage.models import WidgetUser, Department ...@@ -5,5 +5,18 @@ from homepage.models import WidgetUser, Department
def index(request): def index(request):
return HttpResponse("WIDGET USERS:<br>" entries = WidgetUser.objects.all().count()
) n = 1
users = "WIDGET USERS:<br/>"
while (n <= entries):
userLastName = WidgetUser.objects.get(pk=n).last_name
userFirstName = WidgetUser.objects.get(pk=n).first_name
userMiddleName = WidgetUser.objects.get(pk=n).middle_name
userIdNum = WidgetUser.objects.get(pk=n).id_num
userEmail = WidgetUser.objects.get(pk=n).email
userDept = Department.objects.get(widget_user=n).dept_name
userHome = Department.objects.get(widget_user=n).home_unit
users = users + userLastName + ", " + userFirstName + " " + userMiddleName + ": " + userIdNum + ", " + userEmail + ", " + userDept + ", " + userHome + "<br/>"
n += 1
return HttpResponse(users)
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