Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if parent.parent and parent.parent == self:
raise ValidationError(_('Cannot have circular Parents.'))
def save(self, *args, **kwargs):
if not self.slug:
self.slug = slugify(self.name)
return super(Category, self).save(*args, **kwargs)
class Meta:
ordering = ['name']
verbose_name = _("Category")
verbose_name_plural = _("Categories")
class CategoryEntryPage(models.Model):
category = models.ForeignKey(Category, related_name="+", verbose_name=_('Category'), on_delete=models.CASCADE)
page = ParentalKey('EntryPage', related_name='entry_categories')
panels = [
FieldPanel('category')
]
def __str__(self):
return str(self.category)
class TagEntryPage(TaggedItemBase):
content_object = ParentalKey('EntryPage', related_name='entry_tags')
@register_snippet
class Tag(TaggitTag):
objects = TagManager()
def save(self, *args, **kwargs):
if not self.slug:
self.slug = slugify(self.name)
return super(Category, self).save(*args, **kwargs)