Commit 04c70aa6 authored by Pierre Ashley Salcedo's avatar Pierre Ashley Salcedo

feat: update models for homepage app and added new model to admin.py

parent b93bb5c4
from django.contrib import admin from django.contrib import admin
from .models import WidgetUser from .models import Department, WidgetUser
class DepartmentAdmin(admin.ModelAdmin):
model = Department
class WidgetUserAdmin(admin.ModelAdmin): class WidgetUserAdmin(admin.ModelAdmin):
model = WidgetUser model = WidgetUser
# Register your models here. # Register your models here.
admin.site.register(WidgetUser, WidgetUserAdmin) admin.site.register(WidgetUser, WidgetUserAdmin)
admin.site.register(Department, DepartmentAdmin)
from django.db import models from django.db import models
# Create your models here. # Create your models here.
class Department(models.Model):
dept_name = models.CharField(max_length=100)
home_unit = models.CharField(max_length=64)
def __str__(self):
return '{}, {}'.format(
self.dept_name,
self.home_unit,
)
class WidgetUser(models.Model): class WidgetUser(models.Model):
first_name = models.CharField(max_length=50) first_name = models.CharField(max_length=50)
middle_name = models.CharField(max_length=50) middle_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50)
id_num = models.PositiveIntegerField(max_length=7)
email = models.CharField(max_length=320)
department = models.ForeignKey(
Department,
on_delete=models.CASCADE,
default=None,
null=True
)
def __str__(self): def __str__(self):
return '{}, {} {}'.format( return '{}, {} {}'.format(
......
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