From b3d46f2ddbd7312e731e8a05e09a8b547439b2ff Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 29 Jul 2024 17:06:29 +0100 Subject: wip: Adds a new model for additional categories - Adds new ResourceSubcategory - Uses this for choices= in the Resource form (create) - Adds this new model to the admin Doesn't validate in the edit form yet, --- pyblackbird_cc/resources/models.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'pyblackbird_cc/resources/models.py') diff --git a/pyblackbird_cc/resources/models.py b/pyblackbird_cc/resources/models.py index d302ae6..a03992b 100644 --- a/pyblackbird_cc/resources/models.py +++ b/pyblackbird_cc/resources/models.py @@ -46,7 +46,7 @@ class Resource(models.Model): related_name="main_resource_category", ) additional_resource_category = models.ManyToManyField( - "ResourceCategory", + "ResourceSubcategory", null=True, blank=True, related_name="additional_resource_category", @@ -105,6 +105,21 @@ class ResourceType(models.Model): created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) + class Meta: + verbose_name_plural = "Resource Types" + + def __str__(self): + return self.name + + +class ResourceSubcategory(models.Model): + name = models.CharField(max_length=255, null=False) + created_at = models.DateTimeField(auto_now_add=True) + updated_at = models.DateTimeField(auto_now=True) + + class Meta: + verbose_name_plural = "Resource Subcategories" + def __str__(self): return self.name -- cgit v1.2.3