def create_demo_fixtures():
fake = Faker()
name = fake.name()
# have username be demo-username, so demos-users are easy to tell
username = 'demo-{name}'.format(name=name)
username = slugify(username)
# since these are demo accounts, just set the username/pass the same
# so this is a really weird bug since you'd wonder why this would be a get_or_create
# but faker doesn't always generate fake names in celery instances ...
user, _ = User.objects.get_or_create(username=username)
# create a log of this person as a demo user, otherwise we would never be able to tell if someone is a demo or not!
_, created = DemoUserLog.objects.get_or_create(user=user)
if not created:
return
fixtures_builder = DemoHistoricalDataBuilder(user, periods_back=180)
fixtures_builder.create_historical_fixtures()
评论列表
文章目录