Reputation: 3778
I have the following model, using Django Polymorphic:
class Connection(models.Model):
input = BaseInput()
class BaseInput(PolymorphicModel):
pass
class ChildInput(BaseInput):
name = 'child'
Using the python console, doing BaseInput.objects.all() resolves nicely to ChildInput automatically due to Django Polymorphic.
But in the view, the .html file, I use a for loop through Connection.objects.all() (given in the context). If I then try to access the ChildInput object like so:
c.input
(where c is the connection in the for loop) it resolves to 'BaseInput object'.
So Polymorphic works in the python interpreter but not the view.
Any ideas?
(Python 3.4.1, Django 1.7.3, Django-polymorphic 0.6.1)
Upvotes: 2
Views: 329
Reputation: 53669
class Connection(models.Model):
input = BaseInput()
You need to change input
to models.ForeignKey(BaseInput)
. This way, input
is added as a database field on the Connection
model, and not just as an attribute on the class.
Upvotes: 1