Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#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 Christian Peters, 10 years ago

Type: UncategorizedBug

comment:2 by Christian Peters, 10 years ago

Resolution: invalid
Status: newclosed

comment:3 by Christian Peters, 10 years ago

It turned out, that I just need to inherit the mixin from object to make it work in django 1.7

Note: See TracTickets for help on using tickets.
Back to Top