new_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.10.1 on 2016-09-22 11:30
  from __future__ import unicode_literals
  
  from django.db import migrations
  
  
  def set_groupcontent_group(apps, schema_editor):
      Group1 = apps.get_model('entities.Group')
      Group2 = apps.get_model('groups.Group')
      GroupContent = apps.get_model('entities.GroupContent')
      for gc in GroupContent.objects.values('id', 'group_id'):
          g1 = Group1.objects.get(id=gc['group_id'])
          g2 = Group2.objects.get(slug=g1.slug)
          GroupContent.objects.filter(id=gc['id']).update(group_id=g2.id)
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('entities', '0044_auto_20160922_1118'),
      ]
  
      operations = [
          migrations.RunPython(set_groupcontent_group)
      ]
  
subject: Add migration to fix groupcontent foreign key