Commit 9a2c2528 authored by Stefan Gomez's avatar Stefan Gomez

Populated the models for the dashboards app and updated the page to show the...

Populated the models for the dashboards app and updated the page to show the users stored in the database.
parent 9525e3b0
......@@ -11,4 +11,4 @@ class WidgetUserAdmin(admin.ModelAdmin):
admin.site.register(Department, DepartmentAdmin)
admin.site.register(Assignment, AssignmentAdmin)
admin.site.register(WidgetUser, WidgetUserAdmin)
# Generated by Django 4.1.7 on 2023-03-02 13:31
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Department',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('dept_name', models.CharField(max_length=100)),
('home_unit', models.CharField(max_length=100)),
],
),
migrations.CreateModel(
name='WidgetUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.CharField(max_length=100)),
('middle_name', models.CharField(max_length=100)),
('last_name', models.CharField(max_length=100)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='dashboard.department')),
],
),
]
......@@ -5,7 +5,7 @@ class Department(models.Model):
dept_name = models.CharField(max_length=100)
home_unit = models.CharField(max_length=100)
def__str__(self):
def __str__(self):
return '{}, {}'.format(self.dept_name, self.home_unit)
......@@ -15,3 +15,6 @@ class WidgetUser(models.Model):
last_name = models.CharField(max_length=100)
department = models.ForeignKey(Department, on_delete=models.CASCADE)
def __str__(self):
return '{}, {} {}'.format(self.last_name, self.first_name, self.middle_name)
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
from.models import Department, WidgetUser
def index(request):
page_content="""<H1>Welcome to Widget!</H1>
<li>WIDGET USERS:<br>"""
for user in WidgetUser.objects.all():
page_content += """<ul>
<li>{}, {} {}: {}<br>
</ul>""".format(user.last_name, user.first_name, user.middle_name, user.department)
return HttpResponse(page_content)
No preview for this file type
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