#23574 closed Bug (invalid)
Makemigrations tries to migrate non-model classes
Reported by: | Christian Peters | Owned by: | nobody |
---|---|---|---|
Component: | Migrations | Version: | 1.7 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If your model extends non-model classes, the migration fails with:
raise ValueError("Cannot serialize: %r\nThere are some values Django cannot serialize into migration files.\nFor more, see https://docs.djangoproject.com/en/dev/topics/migrations/#migration-serializin
The reason is that before adding the base classes there is no check if the base class is indeed a django model:
https://github.com/django/django/blob/master/django/db/migrations/autodetector.py#L495-505
Solution: Check if the base class is an instance of django.db.model before adding it.
Context:
I have Models with some mixins that just add method and functionality that is shared among multiple models, e.g. an InvoiceMixin, that is shared by multiple models to enrich them with convenience methods.
Change History (3)
comment:1 by , 10 years ago
Type: | Uncategorized → Bug |
---|
comment:2 by , 10 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
It turned out, that I just need to inherit the mixin from object to make it work in django 1.7