我在django 1.6.5中遇到一个奇怪的问题。
from core.models import Book, Person
class Proxy1(Book):
class Meta:
proxy = True
class Proxy2(Person):
class Meta:
proxy = True
>>> from distribution.models import Proxy1, Proxy2
>>> type(Proxy1.objects.first())
<class 'core.models.Book'>
>>> type(Proxy2.objects.first())
<class 'distribution.models.Proxy2'>
任何想法在哪里寻找原因?
答案 0 :(得分:1)
我通过手动覆盖代理类上的'objects'属性来解决这个问题:
class ProxyModel(SomeModelWithMoneyField):
# This fixes django-money that would else return parent objects
objects = models.Manager()
class Meta:
proxy=True