I have the following models:
class Engine(models.Model):
...
def speed(self):
return 100
objects = InheritanceManager()
class TurboEngine(Engine):
...
def speed(self):
return 500
class Car(models.Model):
...
engine = models.ForeignKey(Engine)
No I am using a DetailView on a Car
with a TurboEngine
, but car.engine.speed()
returns 100. How do I make it select the right class?
This is a very nice and interested question, we had the same problem 2 or 3 years ago:
And you must to access of the next way: car.engine.get_real_provider().speed()