[Django] #24310: Data migration for model, that inherited from unmigrated app's model and have FK

6 views
Skip to first unread message

Django

unread,
Feb 9, 2015, 10:20:04 AM2/9/15
to django-...@googlegroups.com
#24310: Data migration for model, that inherited from unmigrated app's model and
have FK
-------------------------------+--------------------
Reporter: GeyseR | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
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 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24310>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 9, 2015, 10:25:41 AM2/9/15
to django-...@googlegroups.com
#24310: Data migration for model, that inherited from unmigrated app's model and
have FK
-------------------------------+--------------------------------------
Reporter: GeyseR | Owner: nobody
Type: Uncategorized | Status: closed
Component: Migrations | Version: 1.7
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_better_patch: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_docs: => 0


Comment:

I don't think we're going to add support for something like this. It's
basically covered by
[https://docs.djangoproject.com/en/1.7/topics/migrations/#dependencies
this documentation note]. You could try adding migrations for the
unmigrated app (using the `MIGRATION_MODULES` setting).

--
Ticket URL: <https://code.djangoproject.com/ticket/24310#comment:1>

Reply all
Reply to author
Forward
0 new messages