Reputation: 785
I have these models:
class Base(models.Model):
# ... attributes
def f(self):
raise Exception()
class A(Base):
attribute = models.IntegerField()
class B(A):
class Meta:
proxy = True
def f(self):
print "B", attribute
class C(A):
class Meta:
proxy = True
def f(self):
print "C", attribute
Now i play a bit with them, but i found a problem:
c = C()
c.attribute = 1
c.save()
b = Base.objects.all()
b.f() # Aspected "C 1" to be printed, exception fired instead!
The last line work in unexpected way! So looking to the documentation better, I searched for the Django automatic downcasting attribute, but i found only the one of the A()
class that haven't automatic casting for neither B()
or C()
.
There's a way to save the inheritance also when i save the data? Thanks!
Upvotes: 0
Views: 120