title: Cannot create an instance of a model with GenericForeignKey in migration
body: <p><strong>IMPORTANT:</strong> This question is no longer relevant.</p>
  
  <hr>
  
  <p>In a Django 1.7 migration I try to create Comment entries programatically with the following code:</p>
  
  <pre class="lang-py prettyprint-override"><code># -*- coding: utf-8 -*-
  from __future__ import unicode_literals
  from django.db import models, migrations
  
  class Migration(migrations.Migration):
  
      def create_genericcomment_from_bookingcomment(apps, schema_editor):
  
          BookingComment = apps.get_model('booking', 'BookingComment')
          Comment = apps.get_model('django_comments', 'Comment')
          for comment in BookingComment.objects.all():
              new = Comment(content_object=comment.booking)
              new.save()
  
      dependencies = [
          ('comments', '0001_initial'),
          ('django_comments', '__first__'),
      ]
  
      operations = [
          migrations.RunPython(create_genericcomment_from_bookingcomment),
      ]
  </code></pre>
  
  <p>And it produces an error:
  <code>TypeError: 'content_object' is an invalid keyword argument for this function</code></p>
  
  <p>However, the same code (i.e. <code>Comment(content_object=comment.booking)</code>) works when executed in the shell.</p>
  
  <p>I tried to create a blank model with <code>new = Comment()</code> and then set all the necessary fields manually but even though I set <code>content_type</code> and <code>object_pk</code> fields accordingly, they <code>content_type</code> was not actually saved and I received <code>django.db.utils.IntegrityError: null value in column "content_type_id" violates not-null constraint</code></p>
  
  <p>Any idea how to properly create a model with a generic foreign key in a migration? Or any workaround?</p>