models

rahul drahul d
1 min read
    class BlogCategory(models.Model):
        name = models.CharField(max_length=100, unique=True)
        description = models.TextField(blank=True, null=True)
        slug = models.SlugField(max_length=100, unique=True, blank=True)
        created_at = models.DateTimeField(auto_now_add=True)
        updated_at = models.DateTimeField(auto_now=True)

        def save(self, *args, **kwargs):
            if not self.slug:
                self.slug = slugify(self.name)  
            super().save(*args, **kwargs)

        def __str__(self):
0
Subscribe to my newsletter

Read articles from rahul d directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

rahul d
rahul d