本文整理匯總了Python中pybb.models.Topic.slug方法的典型用法代碼示例。如果您正苦於以下問題:Python Topic.slug方法的具體用法?Python Topic.slug怎麽用?Python Topic.slug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pybb.models.Topic
的用法示例。
在下文中一共展示了Topic.slug方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_new_topic
# 需要導入模塊: from pybb.models import Topic [as 別名]
# 或者: from pybb.models.Topic import slug [as 別名]
def get_new_topic(self):
if hasattr(self, '_new_topic'):
return self._new_topic
if self.post.is_topic_head:
topic = self.topic
else:
topic = Topic(user=self.post.user)
if topic.name != self.cleaned_data['name']:
topic.name = self.cleaned_data['name']
# force slug auto-rebuild if slug is not speficied and topic is renamed
topic.slug = self.cleaned_data.get('slug', None)
elif self.cleaned_data.get('slug', None):
topic.slug = self.cleaned_data['slug']
topic.forum = Forum.objects.get(pk=self.cleaned_data['move_to'])
topic.slug = create_or_check_slug(topic, Topic, forum=topic.forum)
topic.save()
return topic