Skip to content

Instantly share code, notes, and snippets.

@ryan2clw
Created August 19, 2019 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryan2clw/0c5133e00792d871475af0ddbe34f2ca to your computer and use it in GitHub Desktop.
Save ryan2clw/0c5133e00792d871475af0ddbe34f2ca to your computer and use it in GitHub Desktop.
data migration
# Generated by Django 2.2.4 on 2019-08-19 15:30
from django.db import migrations
def seed_database(apps, _):
""" Seed the ball numbers into the database """
balls = apps.get_model('play', 'Ball')
balls.objects.all().delete()
for i in range(1, 76):
data = {
"num_value" : i,
"is_played" : False
}
ball = balls.objects.create(**data)
ball.save()
class Migration(migrations.Migration):
""" Seeds ball data """
dependencies = [
('play', '0006_auto_20190819_1447'),
]
operations = [
migrations.RunPython(seed_database)
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment