minor update

This commit is contained in:
2025-08-25 13:12:36 +05:30
parent ffe2c93ae2
commit c3b5ec78fc
9 changed files with 127 additions and 21 deletions
+14 -4
View File
@@ -1,5 +1,6 @@
from django.contrib.auth.models import AbstractUser
from django.core.validators import FileExtensionValidator
from django.conf import settings
from django.db import models
class User(AbstractUser):
@@ -98,15 +99,24 @@ class Department(models.Model):
description = models.TextField(blank=True, null=True)
created_at = models.DateTimeField(auto_now_add=True)
# Each department can have many users
users = models.ManyToManyField(
User,
settings.AUTH_USER_MODEL,
related_name="departments",
blank=True,
limit_choices_to={'is_staff': True}
blank=True
)
# One admin per department
admin = models.OneToOneField(
settings.AUTH_USER_MODEL,
on_delete=models.SET_NULL,
related_name="admin_of_department",
null=True,
blank=True
)
class Meta:
ordering = ["name"]
def __str__(self):
return self.name.name
return self.name