old_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.9.7 on 2016-08-26 15:12
  from __future__ import unicode_literals
  
  from django.db import migrations
  
  
  def set_app_labels(apps, schema_editor):
      RawData = apps.get_model('share', 'RawData')
      for raw in RawData.objects.all():
          raw.app_label = raw.source.username.rpartition('providers.')[2]
          raw.save()
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('share', '0030_rawdata_app_label'),
      ]
  
      operations = [
          migrations.RunPython(set_app_labels)
      ]
  
new_contents: # -*- coding: utf-8 -*-
  # Generated by Django 1.9.7 on 2016-08-26 15:12
  from __future__ import unicode_literals
  
  from django.db import migrations
  
  
  def set_app_labels(apps, schema_editor):
      RawData = apps.get_model('share', 'RawData')
      for raw in RawData.objects.select_related('source').all():
          raw.app_label = raw.source.username.rpartition('providers.')[2]
          raw.save()
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('share', '0030_rawdata_app_label'),
      ]
  
      operations = [
          migrations.RunPython(set_app_labels, reverse_code=migrations.RunPython.noop)
      ]
  
subject: Improve app_label migration