given the following models.py:
{{{
from django.db import models
from hvad.models import TranslatableModel, TranslatedFields
class MyMixin(object):
pass
# Fails
class MyModelA(TranslatableModel, MyMixin):
translations = TranslatedFields(
name=models.CharField(max_length=60),
)
# Works
class MyModelB(TranslatableModel):
translations = TranslatedFields(
name=models.CharField(max_length=60),
)
# Works
class MyModelC(models.Model, MyMixin):
name=models.CharField(max_length=60),
# Works obviously
class MyModelD(models.Model):
name=models.CharField(max_length=60),
}}}
Removing MyMixin from MyModelA and re-running migrate works (deleted the
sqlite db first):
{{{
Operations to perform:
Synchronize unmigrated apps: admin, contenttypes, langapp, auth,
sessions
Apply all migrations: (none)
Synchronizing apps without migrations:
Creating tables...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table langapp_mymodela_translation
Creating table langapp_mymodela
Creating table langapp_mymodelb_translation
Creating table langapp_mymodelb
Creating table langapp_mymodelc
Creating table langapp_mymodeld
Installing custom SQL...
Installing indexes...
Installed 0 object(s) from 0 fixture(s)
Running migrations:
No migrations needed.
You have installed Django's auth system, and don't have any superusers
defined.
Would you like to create one now? (yes/no): no
}}}
These tests have been conducted with hvad master (github) and django
master (github)
--
Ticket URL: <https://code.djangoproject.com/ticket/21786>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
posted after discussion with andrewgodwin in #django-dev
some thoughts:
- migrate still runs models through a serialise/deserialise cycle
- it runs autodetect to see if you have changes
- perhaps not serialising properly
--
Ticket URL: <https://code.djangoproject.com/ticket/21786#comment:1>
* owner: => andrewgodwin
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/21786#comment:2>
* cc: timo (added)
* stage: Unreviewed => Accepted
Comment:
I also ran across a similar issue but didn't distill it to a simple
example like Gabe has done.
--
Ticket URL: <https://code.djangoproject.com/ticket/21786#comment:3>
Comment (by andrewgodwin):
I can't replicate this, as django-hvad doesn't work against 1.7 trunk. Can
it be reduced to something that doesn't depend on an external app?
--
Ticket URL: <https://code.djangoproject.com/ticket/21786#comment:4>
Comment (by andrewgodwin):
Nevermind, I managed to get it working enough to debug the issue -
migrations ignores any abstract bases (which TranslatableModel is one of),
and if there's no bases at all adds models.Model as a base, but if you had
a mixin it had bases but none were from Model. I've pushed a fix.
Looking at the hvad code, I wouldn't be surprised if it needs other
updates for 1.7 as it's doing some weird things with models, but that's to
be expected, I guess. It at least doesn't immediately fail now.
--
Ticket URL: <https://code.djangoproject.com/ticket/21786#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"1f5268a01f82c314b48d195b7d7a344f9db58b6d"]:
{{{
#!CommitTicketReference repository=""
revision="1f5268a01f82c314b48d195b7d7a344f9db58b6d"
Fixed #21786: Bad behaviour when mixins + abstract bases for migrations
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21786#comment:6>