def test_model_creation(self): """ Basic test for Post model creation. """ post = G(Post, title="This is a test post.", slug="", author=self.staff) self.assertTrue(post.content_markup, str(markup(post.content))) self.assertTrue(isinstance(post, Post)) self.assertEquals(post.__unicode__(), post.title) self.assertEquals(post.slug, slugify(post.title))
def save(self, *args, **kwargs): self.content_markup = str(markup(self.content)) self.author_name = str(get_user_model().objects.get(id=self.author.id).username) if isinstance(self.updated_at, datetime.date): self.updated_at_beautified = str(self.updated_at.today().strftime("%d, %b %Y")) if not self.slug: self.slug = slugify(self.title) super(Post, self).save(*args, **kwargs)
def save(self, *args, **kwargs): self.content_markup = markup(self.content) if not self.slug: self.slug = slugify(self.title) super(Post, self).save(*args, **kwargs)