Commit ee420b92 authored by Vaughn Fajardo's avatar Vaughn Fajardo

feat: browser display for widgetuser model

parent 80ac4792
# Generated by Django 4.0.3 on 2022-04-01 13:48
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0005_remove_department_widgetuser_widgetuser_department'),
]
operations = [
migrations.AlterField(
model_name='widgetuser',
name='department',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='department', to='homepage.department'),
),
]
......@@ -13,7 +13,7 @@ class WidgetUser(models.Model):
last_name = models.CharField(max_length=50)
id_num = models.IntegerField(max_length=7, null=True)
email = models.EmailField(max_length=50, null=True)
department = models.ForeignKey(Department, on_delete=models.CASCADE, null=True)
department = models.ForeignKey(Department, on_delete=models.CASCADE, null=True, related_name='department')
def __str__(self):
return self.first_name
\ No newline at end of file
......@@ -3,5 +3,6 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index')
path('', views.index, name='index'),
path('welcome', views.welcome, name='welcome')
]
\ No newline at end of file
from django.shortcuts import render
from django.http import HttpResponse
from .models import Department, WidgetUser
# Create your views here.
def welcome(request):
return HttpResponse('Welcome to Widget!')
def index(request):
return HttpResponse('Welcome to Widget!')
\ No newline at end of file
WidgetUserView = 'WIDGET USERS: '
widgetuser = WidgetUser.objects.all()
for user in widgetuser:
WidgetUserView += "<br/> {}, {} {}: {}, {}, {}, {}".\
format(user.last_name,
user.first_name,
user.middle_name,
user.id_num,
user.email,
user.department.dept_name,
user.department.home_unit)
return HttpResponse(WidgetUserView)
\ 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