Fix slug generation in wizard

This commit is contained in:
Iacopo Spalletti 2016-10-24 18:22:56 +02:00
parent 78001259a1
commit ff7d97b67c
No known key found for this signature in database
GPG Key ID: BDCBC2EB289F60C6
3 changed files with 7 additions and 0 deletions

View File

@ -9,6 +9,7 @@ History
******************
* Optimized querysets
* Fixed slug generation in wizard
******************
0.8.8 (2016-09-04)

View File

@ -221,6 +221,8 @@ class Post(KnockerModel, ModelMeta, TranslatableModel):
"""
if self.publish and self.date_published is None:
self.date_published = timezone.now()
if not self.slug and self.title:
self.slug = slugify(self.title)
super(Post, self).save(*args, **kwargs)
def save_translation(self, translation, *args, **kwargs):

View File

@ -439,6 +439,10 @@ class AdminTest(BaseTest):
class ModelsTest(BaseTest):
def test_slug(self):
post = Post.objects.language('en').create(title='I am a title')
self.assertEqual(post.slug, 'i-am-a-title')
def test_model_attributes(self):
self.get_pages()