modelview

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): return self.name

Mar 28, 2025 - 04:15
 0
modelview
    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):
            return self.name