Opened 11 years ago
Closed 11 years ago
#22416 closed Cleanup/optimization (needsinfo)
Migrate can't create ManyToManyField for Model migrated in the same run
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Migrations | Version: | 1.7-alpha-2 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I have a fresh database and created the inital migrations.
When trying to apply the migrations with 'migrate <appname>', I get
django.db.utils.ProgrammingError: (1146, "Table '<WEBSITENAME>.django_content_type' doesn't exist")
Makes sense so far as django_content_type is from another app.
Running 'migrate' (without app name) runs through my first app OK.
When it runs through the migrations for the second app, I get
ValueError: Related model 'appname.Modelname' cannot be resolved
I checked the spelling in the migrations inital file, it's fine.
The Model with the field which gives the error contains 2 ManyToManyFields, let's call them A and B for convenience. They are identical except for the model they reference.
Field A relates to a model from a third app,
which has not been handled by migrations by then.
Field B relates to a model from the first app.
In the migrations file (and the model), Field A is mentioned first and gives no errors.
Field B is mentioned after Field A and raises the ValueError.
Change History (3)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Triage Stage: | Unreviewed → Accepted |
---|
This might be a duplicate of some other ticket, but it's difficult to say. A minimal project (or ideally a test for Django's test suite) would be really helpful.
comment:3 by , 11 years ago
Resolution: | → needsinfo |
---|---|
Status: | new → closed |
Summary: | Migrate can't create ManyToManyField for Model wigrated in the same run → Migrate can't create ManyToManyField for Model migrated in the same run |
I tried reproducing the second issue this based on the given info but could not. Please reopen if you can reproduce on the latest master or 1.7.x with additional details.
The django_content_type bug sounds like a duplicate of #22411.