diff options
author | Matthew Lemon <y@yulqen.org> | 2024-07-29 17:06:29 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-07-29 17:06:29 +0100 |
commit | b3d46f2ddbd7312e731e8a05e09a8b547439b2ff (patch) | |
tree | 70fc0e4487dee1ee2f2febf083f35a7a0a38721e /pyblackbird_cc/resources/models.py | |
parent | 914fb4dd4ab8b7e37c67de01d6a42802999553c1 (diff) |
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,
Diffstat (limited to 'pyblackbird_cc/resources/models.py')
-rw-r--r-- | pyblackbird_cc/resources/models.py | 17 |
1 files changed, 16 insertions, 1 deletions
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 |