-
Notifications
You must be signed in to change notification settings - Fork 159
Error when creating ordered model in migration #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi embeddedt - did you get any further with this? I would be happy to add a default True value if you can confirm it helps. |
I ended up working around it for now by adding Unfortunately, it seems that setting |
I suspect that without Alternatively, if |
Thanks for the comments. I did try sometime last year to write a unit test that covered running a migration that created a model, based on the Django unit tests, but it was superbly complicated and I couldn't justify the time to fully debug what was happening. Without a decent test case I left the ticket. The Meta class (regrettably) is the right place for this configuration. Django introduced similar, but not identical functionality using the I would certainly review and work towards a patch to support setting these values on the Meta, and fixing up our docs and checks to validate them. We could use the old fields on the model as a fallback, raising a warning to help migrate. Especially if that is all that is actually required to make our manager work during a migration. |
Currently, it is impossible to add custom attributes to Meta. There are discussion about this in https://code.djangoproject.com/ticket/5793, which suggested Django core to support this. However, it's been a while since the last activity. I've tried monkey patching on the Django core Meta options, but don't think it will work consistently since there is no guarantee that the library can apply the monkey patch before Django is loaded. It will also be hard to maintain given that Meta is heavily used in Django, and might break things (or other libraries) due to the patch. |
In the past I've made migrations which look like this:
The previous versions of this migration which were made before
MyModel
inherited fromOrderedModel
work fine.However, when I make a new version of the migration with the OrderedModel version, it fails with the following error:
I suspect the reason this occurs is because the
OrderedModelManager
does not haveuse_in_migrations
set to True.The text was updated successfully, but these errors were encountered: