Commit bbdd760c authored by Ian Rafael T. Aragoza's avatar Ian Rafael T. Aragoza

Add Department and WidgetUser models for dashboard app

parent 406218d3
Pipeline #2931 canceled with stages
# Generated by Django 4.1.7 on 2023-03-04 11:59
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=48, unique=True)),
('home_unit', models.CharField(max_length=48)),
],
),
migrations.CreateModel(
name='WidgetUser',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('first_name', models.TextField(max_length=48)),
('middle_name', models.TextField(max_length=48)),
('last_name', models.TextField(max_length=48)),
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='department', to='dashboard.department')),
],
),
]
from django.db import models from django.db import models
# Create your models here. # Create your models here.
from django.db import models
from django.urls import reverse
class Department(models.Model):
dept_name = models.CharField(max_length=48, unique=True)
home_unit = models.CharField(max_length=48)
def __str__(self):
return '{}'.format(self.dept_name)
def get_absolute_url(self):
return reverse('department_detail', args=[str(self.dept_name)])
class WidgetUser(models.Model):
first_name = models.TextField(max_length=48)
middle_name = models.TextField(max_length=48)
last_name = models.TextField(max_length=48)
department = models.ForeignKey(Department, on_delete=models.CASCADE, related_name='department')
def __str__(self):
return '{}, {} {}'.format(self.last_name, self.first_name, self.middle_name)
def get_absolute_url(self):
return reverse('user_detail', args=[str(self.last_name)])
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