﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
24310	Data migration for model, that inherited from unmigrated app's model and have FK	Sergey Fursov	nobody	"I have problem with migrating data in my project.
I've implemented my own comment model inherited from {{{ django.contrib.comments.Comment }}} model, but this can be any concrete model from unmigrated app. 
And now I want to migrate some data to my comment model. But I can't get full model with foreign keys, because [https://github.com/django/django/blob/master/django/db/migrations/state.py#L143 this] and then [https://github.com/django/django/blob/master/django/db/migrations/state.py#L255 this] lines throw FK away from model and finally I get this exception:
{{{
Traceback (most recent call last):
  File ""./manage.py"", line 10, in <module>
    execute_from_command_line(sys.argv)
  File ""/home/geyser/.virtualenvs/ostankino_crm/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 385, in execute_from_command_line
    utility.execute()
  File ""/home/geyser/.virtualenvs/ostankino_crm/local/lib/python2.7/site-packages/django/core/management/__init__.py"", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/home/geyser/.virtualenvs/ostankino_crm/local/lib/python2.7/site-packages/django/core/management/base.py"", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""/home/geyser/.virtualenvs/ostankino_crm/local/lib/python2.7/site-packages/django/core/management/base.py"", line 338, in execute
    output = self.handle(*args, **options)
  File ""/home/geyser/.virtualenvs/ostankino_crm/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py"", line 161, in handle
    executor.migrate(targets, plan, fake=options.get(""fake"", False))
  File ""/home/geyser/.virtualenvs/ostankino_crm/local/lib/python2.7/site-packages/django/db/migrations/executor.py"", line 68, in migrate
    self.apply_migration(migration, fake=fake)
  File ""/home/geyser/.virtualenvs/ostankino_crm/local/lib/python2.7/site-packages/django/db/migrations/executor.py"", line 102, in apply_migration
    migration.apply(project_state, schema_editor)
  File ""/home/geyser/.virtualenvs/ostankino_crm/local/lib/python2.7/site-packages/django/db/migrations/migration.py"", line 105, in apply
    operation.database_forwards(self.app_label, schema_editor, project_state, new_state)
  File ""/home/geyser/.virtualenvs/ostankino_crm/local/lib/python2.7/site-packages/django/db/migrations/operations/special.py"", line 117, in database_forwards
    self.code(from_state.render(), schema_editor)
  File ""/home/geyser/coding/ostankino_crm/comments_crm/migrations/0003_auto_20150209_1643.py"", line 33, in forward
    comment = MyComment(content_type=ct, object_pk=order.id, comment_type='complain', complain_status=2 if order.complaint_resolved else None, user=change_user, comment=order.status_desc, submit_date=change_date)
  File ""/home/geyser/.virtualenvs/ostankino_crm/local/lib/python2.7/site-packages/django/db/models/base.py"", line 452, in __init__
    raise TypeError(""'%s' is an invalid keyword argument for this function"" % list(kwargs)[0])
TypeError: 'user' is an invalid keyword argument for this function
}}}

Also I've attached minimal project that reproduces this error, just execute {{{ ./manage.py migrate }}}"	Uncategorized	closed	Migrations	1.7	Normal	invalid			Unreviewed	0	0	0	0	0	0
