Opened 10 years ago
Closed 10 years ago
#24310 closed Uncategorized (invalid)
Data migration for model, that inherited from unmigrated app's model and have FK
Reported by: | Sergey Fursov | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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 this and then 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
Attachments (1)
Change History (2)
by , 10 years ago
Attachment: | django1.tar.gz added |
---|
comment:1 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
I don't think we're going to add support for something like this. It's basically covered by this documentation note. You could try adding migrations for the unmigrated app (using the MIGRATION_MODULES
setting).
example project