本文整理汇总了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()