-
-
Notifications
You must be signed in to change notification settings - Fork 302
Closed
Labels
Description
Let's say we have the following models:
class Base(PolymorphicModel):
name = models.CharField(max_length=30)
class Foo(Base):
foo = models.CharField(max_length=30)
We can't set Foo.foo because Foo.foo is overwritten as an attribute referencing itself... (i believe that is happening here):
>>> Foo.objects.create(foo='some foo text')
ValueError: Cannot assign "'some foo text'": "Foo.foo" must be a "Foo" instance.
In fact, if model Bar is a subclass of Base and has a foo field/method/property, we have the same problem, because the foo attribute for every subclass of Base is trying to reference a Foo instance.
i'm not sure what the internal use of that property is, but how about we allow the name of the property to be overridden (via a method on the base class which could be overridden), or perhaps auto-generate a name like _foo instead? Otherwise, this means that no field on any child model can match the name of its own class or of a class having the same base.