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


Python Activity.owner方法代码示例

本文整理汇总了Python中activity.models.Activity.owner方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.owner方法的具体用法?Python Activity.owner怎么用?Python Activity.owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在activity.models.Activity的用法示例。


在下文中一共展示了Activity.owner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: handle

# 需要导入模块: from activity.models import Activity [as 别名]
# 或者: from activity.models.Activity import owner [as 别名]
    def handle(self, *args, **options):
        number = int(options['number'][0])
        print(options['number'])
        
        for i in range(number):
            print("Creating user {} of {}".format(i+1, number))
            user = User()
            user.username = self.get_username()
            user.first_name = self.get_username().capitalize()
            user.last_name = self.get_username().capitalize()
            user.password = make_password("password")
            user.email = fake.email()
            user.save()
        print("Done. Created {} users".format(i+1))

        print("==================================UserActivities=========================")
        users = User.objects.all()
        for user in users:            
            for activiti in activities:
                activity = Activity()
                activity.owner = user
                activity.activity_name = activiti
                activity.save()
                
        print("=================Statistics======================")
        
        user_activities = Activity.objects.all()
        for i in range(10):
            print("Activities round {}".format(i))
            for activity in user_activities:
                print("User {}".format(activity.owner.username))
                activity_stat = ActivityStatistics()
                activity_stat.activity = activity
                activity_stat.owner = activity.owner
                activity_stat.value = random.randint(3, 20)
                activity_stat.statistics_date = fake.date()
                activity_stat.save()
开发者ID:stat-track-group,项目名称:stat-tracker,代码行数:39,代码来源:createusers.py


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