Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#24052 closed Cleanup/optimization (fixed)

Document how to use models from other apps in RunPython

Reported by: Aymeric Augustin Owned by: nobody
Component: Documentation Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

A common use case for RunPython (known in South as data migrations) is to port data from one model to another. When you do this across apps, you must add the other app to dependencies. Otherwise you get a moderately helpful:
LookupError: No installed app with label 'people'.

Do you think it's worth documenting?

Change History (9)

comment:1 by Aymeric Augustin, 9 years ago

Here's an interesting variant of this problem.

If you attempt to use a relation that's defined in another app, the relation doesn't exist unless you include that app in your dependencies.

comment:2 by Tim Graham, 9 years ago

Description: modified (diff)
Triage Stage: UnreviewedAccepted

Definitely. I thought this came up before, but I can't find a ticket or any docs.

comment:3 by Markus Holtermann, 9 years ago

This should definitely be covered in the docs. The only thing I can recall to have read somewhere are the few lines I wrote down in my Django 1.7: Database Migrations done right blog post.

Last edited 9 years ago by Markus Holtermann (previous) (diff)

comment:4 by Bibhas C Debnath, 9 years ago

I recently faced this when migrating a model which had an FK to a custom user model. The custom user model was added in the migration 0002 of my accounts app. I had to manually add 0002_migration_name to the dependency list for the migration to work, otherwise it'd just complain that it can't find the custom user model. The user models migration was not added to the dependency list automatically. I'll check if I can reproduce this. This happened during the migration that was reported in #24037.

comment:5 by Tim Graham, 9 years ago

Has patch: set

comment:6 by Tim Graham, 9 years ago

Patch needs improvement: set

comment:7 by Tim Graham <timograham@…>, 9 years ago

Resolution: fixed
Status: newclosed

In b089759:

Fixed #24052 -- Doc'd how to write data migrations with models in multiple apps.

comment:8 by Tim Graham <timograham@…>, 9 years ago

In 9bb451ae:

[1.7.x] Fixed #24052 -- Doc'd how to write data migrations with models in multiple apps.

Backport of b089759d6025582f36fbea3c4be3855c50b82462 from master

comment:9 by Tim Graham <timograham@…>, 9 years ago

In 937c8a5a:

[1.8.x] Fixed #24052 -- Doc'd how to write data migrations with models in multiple apps.

Backport of b089759d6025582f36fbea3c4be3855c50b82462 from master

Note: See TracTickets for help on using tickets.
Back to Top