This commit is contained in:
bkfox 2019-10-11 16:42:07 +02:00
parent cb51dca5bb
commit 2d2e663124

View File

@ -65,8 +65,8 @@ class Page(models.Model):
parent = models.ForeignKey('self', models.CASCADE, blank=True, null=True, parent = models.ForeignKey('self', models.CASCADE, blank=True, null=True,
related_name='child_set') related_name='child_set')
title = models.CharField(max_length=128) title = models.CharField(max_length=100)
slug = models.SlugField(_('slug'), blank=True, unique=True) slug = models.SlugField(_('slug'), max_length=120, blank=True, unique=True)
status = models.PositiveSmallIntegerField( status = models.PositiveSmallIntegerField(
_('status'), default=STATUS_DRAFT, choices=STATUS_CHOICES, _('status'), default=STATUS_DRAFT, choices=STATUS_CHOICES,
) )
@ -99,7 +99,7 @@ class Page(models.Model):
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if not self.slug: if not self.slug:
self.slug = slugify(self.title) self.slug = slugify(self.title)[:100]
count = Page.objects.filter(slug__startswith=self.slug).count() count = Page.objects.filter(slug__startswith=self.slug).count()
if count: if count:
self.slug += '-' + str(count) self.slug += '-' + str(count)