Skip to content

model fields/properties/methods are being clobbered #266

@smcoll

Description

@smcoll

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions