diff options
author | lxf <sng@luxagraf.net> | 2021-01-07 16:49:29 -0500 |
---|---|---|
committer | lxf <sng@luxagraf.net> | 2021-01-07 16:49:29 -0500 |
commit | e61f3d2c4537a2670c40b33eb02231a71dfb028a (patch) | |
tree | 587120b5a497c9e70d46e3eae7d1a219b5d4858b /app/taxonomy/models.py | |
parent | 534fcd39b1e8d24556d3bf110245a7373ee0eeb6 (diff) |
added a photograpy section by tweaking Category model and then adding
some urls
Diffstat (limited to 'app/taxonomy/models.py')
-rw-r--r-- | app/taxonomy/models.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/app/taxonomy/models.py b/app/taxonomy/models.py index 4db3294..6cc1769 100644 --- a/app/taxonomy/models.py +++ b/app/taxonomy/models.py @@ -3,6 +3,8 @@ from django.urls import reverse from django.utils.translation import ugettext_lazy as _ from django.utils.functional import cached_property +from utils.util import markdown_to_html + from taggit.models import TagBase, GenericTaggedItemBase @@ -27,7 +29,10 @@ class TaggedItems(GenericTaggedItemBase): class Category(models.Model): """ Generic model for Categories """ name = models.CharField(max_length=250) - pluralized_name = models.CharField(max_length=60, null=True) + pluralized_name = models.CharField(max_length=60, null=True, blank=True) + description = models.CharField(max_length=300, null=True, blank=True) + intro_markdown = models.TextField(null=True, blank=True) + intro_html = models.TextField(null=True, blank=True) slug = models.SlugField(blank=True) color_rgb = models.CharField(max_length=20, blank=True) date_created = models.DateTimeField(blank=True, auto_now_add=True, editable=False) @@ -42,3 +47,9 @@ class Category(models.Model): def get_absolute_url(self): return reverse("taxonomy:cat-detail", kwargs={"slug": self.slug}) + + + def save(self, *args, **kwargs): + if self.intro_markdown: + self.intro_html = markdown_to_html(self.intro_markdown) + super(Category, self).save(*args, **kwargs) |