Meta attributes for Model refused to work with Mixin.
|Reported by:||xuqingkuang||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.2|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Hi, I defined a mixin for global usage but it looks it's refused to working with unique_together meta attribute.
Code is following:
from django.db import models class CommonModelMixin(object): name = models.CharField(max_length=1024) description = models.TextField() creator = models.ForeignKey('auth.User', blank=True, null=True, default=None, editable=False) creation_date = models.DateTimeField(auto_now_add=True) class Data(CommonModelMixin, models.Model): product = models.CharField(max_length=1024) class Meta: unique_together = ('product', 'name') class Order(CommonModelMixin, models.Model): is_active = models.BooleanField(default=True) class Meta: ordering = ['is_active', 'name']
But when syncdb it just report:
$ ./manager.py syncdb Error: One or more models did not validate: app.data: "unique_together" refers to name, a field that doesn't exist. Check your syntax. app.order: "ordering" refers to "name", a field that doesn't exist.
I won't to inherit the mixin class from models.Model, because I have other mixins need to define, but it breaks the logical.
Any idea about it ?