本文整理汇总了Python中models.Comment.add_root方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.add_root方法的具体用法?Python Comment.add_root怎么用?Python Comment.add_root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Comment
的用法示例。
在下文中一共展示了Comment.add_root方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import add_root [as 别名]
def post(self, request, *arg, **kwargs):
if self.request.accepted_renderer.format == 'html':
form = PitchForm(request.POST)
if form.is_valid():
pitch = form.save(commit=False)
pitch.creator = request.user
pitch.group_id = kwargs["group_pk"]
pitch.save()
Comment.add_root(creator=User.objects.all()[0],
content_object=pitch, text='')
return redirect('/groups/' + str(kwargs["group_pk"]))
示例2: populate_db
# 需要导入模块: from models import Comment [as 别名]
# 或者: from models.Comment import add_root [as 别名]
def populate_db():
get = lambda id: Comment.objects.get(pk=id)
chad = User.objects.create(username='chad', password=make_password('chad'), email='[email protected]')
brad = User.objects.create(username='brad', password=make_password('brad'), email='[email protected]')
secsi = Group.objects.create(name='SECSI', creator=chad, description='South East Complex Systems Institute')
secsi.members.add(chad)
secsi.members.add(brad)
secsi.save()
p1 = secsi.pitch_set.create(creator=chad, title='let\'s get a keg.', text="okay bros we " +
"know we can't throw a rager and get all " +
"the other bros over if we don't have a keg. " +
"let's get a keg.")
croot = Comment.add_root(creator=User.objects.all()[1], text='', content_object=p1)
c1 = get(croot.pk).add_child(creator=brad, text='fuckkk bro i got so hammered at that ' +
'last kegger that i broke my keg tap. im good for the cash '
'but since that last dui it\'s hard to get down to liqueur loft.'
'can one of you get another tap?')
c2 = get(c1.pk).add_child(creator=chad, text='np bro i still have the one from the throwdown at blake\'s.')