# Generated by Django 2.0.5 on 2018-12-08 05:17

from django.db import migrations

def populate_popularity(apps, schema_editor):
    Game = apps.get_model('games', 'Game')
    GameLibrary = apps.get_model('games', 'GameLibrary')
    for game in Game.objects.all():
        game.popularity = GameLibrary.objects.filter(games=game).count()
        game.save()

class Migration(migrations.Migration):

    dependencies = [
        ('games', '0034_game_popularity'),
    ]

    operations = [
        migrations.RunPython(populate_popularity),
    ]

Add migration for popularity