本文整理汇总了Python中jmbo.models.ModelBase.title方法的典型用法代码示例。如果您正苦于以下问题:Python ModelBase.title方法的具体用法?Python ModelBase.title怎么用?Python ModelBase.title使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jmbo.models.ModelBase
的用法示例。
在下文中一共展示了ModelBase.title方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_generate_slug
# 需要导入模块: from jmbo.models import ModelBase [as 别名]
# 或者: from jmbo.models.ModelBase import title [as 别名]
def test_generate_slug(self):
# on save a slug should be set
obj = ModelBase(title='utils test case title')
obj.save()
self.failIf(obj.slug == '')
# slug should become sluggified version of title
obj = ModelBase(title='utils test case title 1')
obj.save()
self.failUnless(obj.slug == slugify(obj.title))
# no two items should have the same slug
obj = ModelBase(title='utils test case title 1')
obj.save()
# in case an object title is updated, the slug not be updated
obj.title = "updated title"
obj.save()
self.failIf(obj.slug == slugify(obj.title))
# In case an object is updated, without the title being changed
# the slug should remain unchanged.
orig_slug = obj.slug
obj.save()
self.failUnless(obj.slug == orig_slug)
# make sure the slug is actually saved
obj = ModelBase.objects.get(id=obj.id)
self.failIf(obj.slug == '')
# Empty slugs might trip up regex query.
obj = ModelBase()
obj.save()
obj = ModelBase()
obj.save()
obj = ModelBase()
obj.save()