def create_slug(self, diary_id): self.slug = utils.slugify(self.title) counter = 0 new = self.slug while self.query.filter(Post.slug == new, Post.diary_id == diary_id).first() is not None: counter += 1 new = "{0}-{1}".format(self.slug, counter) self.slug = new
def create_slug(self): self.slug = utils.slugify(self.title) counter = 0 new = self.slug while self.query.filter(Diary.slug == new).first() is not None: counter += 1 new = "{0}-{1}".format(self.slug, counter) self.slug = new
def __init__(self, title): self.title = title self.slug = utils.slugify(title)