当前位置: 首页>>代码示例>>Python>>正文


Python Comment.add_root方法代码示例

本文整理汇总了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"]))
开发者ID:TownHall,项目名称:TownHall,代码行数:13,代码来源:views.py

示例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.')
开发者ID:TownHall,项目名称:TownHall,代码行数:20,代码来源:populate_db.py


注:本文中的models.Comment.add_root方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。