Opened 12 years ago
Closed 12 years ago
#21283 closed Bug (fixed)
Migrations created in wrong directory for models defined in model package
| Reported by: | anonymous | Owned by: | Markus Holtermann |
|---|---|---|---|
| Component: | Migrations | Version: | dev |
| Severity: | Normal | Keywords: | |
| Cc: | info@… | Triage Stage: | Accepted |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | yes | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Django supports to split a bunch of models into a separate Python modules which are placed in a models Python package. However the django.db.migrations.writer.MigrationWriter does not reflect this fact in its path property.
The solution is easy:
If myapp.models is a Python app_module (currently line 61) has a __path__ attribute. If it is a Python module there is no such attribute.
I'm going to write a patch and open a pull request for further discussion.
Change History (8)
comment:1 by , 12 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 12 years ago
| Has patch: | set |
|---|---|
| Needs tests: | set |
| Owner: | changed from to |
| Status: | new → assigned |
comment:3 by , 12 years ago
| Cc: | added |
|---|---|
| Owner: | changed from to |
comment:4 by , 12 years ago
Could you make a separate test app like "migrations_model_package" and make sure migrations are properly generated there?
comment:5 by , 12 years ago
@timo, shouldn't this use the app cache methods that you reworked at some point to better deal with models in exotic locations?
As for testing, dunno if this is going to play nice with MIGRATION_MODULES that we need to use in tests.
comment:6 by , 12 years ago
That would be get_app_path() introduced in 31c13a99bb9ebdaf12ccab4e880c5da930d86e79, I think.
comment:7 by , 12 years ago
I had a go at this https://github.com/django/django/pull/1772, feedback welcome.
comment:8 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | assigned → closed |
The pull request is at https://github.com/django/django/pull/1763
Right know I don't have a clue how to write a test case for this issue.