Commit 389bc251 authored by Ramon Angelo Enriquez's avatar Ramon Angelo Enriquez

Added the new homepage DB attributes (id no., email) as well as the department DB

parent a8622d58
from django.contrib import admin
from .models import WidgetUser
from .models import WidgetUser, Department
# Register your models here.
admin.site.register(WidgetUser)
class DepartmentAdminInline(admin.TabularInline):
model = Department
class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser
inlines = [DepartmentAdminInline]
class DepartmentAdmin(admin.ModelAdmin):
model = Department
admin.site.register(WidgetUser, WidgetUserAdmin)
admin.site.register(Department, DepartmentAdmin)
# Generated by Django 4.0.3 on 2022-03-25 18:37
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('homepage', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='widgetuser',
name='email',
field=models.CharField(max_length=50, null=True),
),
migrations.AddField(
model_name='widgetuser',
name='id_num',
field=models.CharField(max_length=7, null=True),
),
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=50)),
('home_unit', models.CharField(max_length=50)),
('widget_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='homepage.widgetuser')),
],
),
]
......@@ -6,6 +6,18 @@ class WidgetUser(models.Model):
first_name = models.CharField(max_length=50)
middle_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
id_num = models.CharField(max_length=7, null=True)
email = models.CharField(max_length=50, null=True)
def __str__(self):
return self.first_name + " " + self.last_name
class Department(models.Model):
widget_user = models.ForeignKey(WidgetUser, on_delete=models.CASCADE,
blank=True, null=True)
dept_name = models.CharField(max_length=50)
home_unit = models.CharField(max_length=50)
def __str__(self):
return self.dept_name + ", " + self.home_unit
from django.http import HttpResponse
from homepage.models import WidgetUser, Department
# Create your views here.
def index(request):
return HttpResponse("Welcome to Widget!")
return HttpResponse("WIDGET USERS:<br>"
)
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