Migrate can't create ManyToManyField for Model migrated in the same run
|Reported by:||roughdesignapps@…||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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 Changed 17 months ago by melinath
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset