Django Inherited Field Access

Posted by Rick on Stack Overflow See other posts from Stack Overflow or by Rick
Published on 2010-04-21T12:39:19Z Indexed on 2010/04/21 13:53 UTC
Read the original article Hit count: 235

Filed under:

As of the most current version, Django does not allow a subclass to have a variable with the same name as a variable in its superclass, if that variable is a Field instance.

I need a subclass to modify this variable, which I call 'department'. Calling my classes super and sub, I need sub to modify the department variable it inherits from super. If I redeclare it, Django throws a field error. Of course, if I don't, department is not in scope for reassignment. If super has no department I get database errors. I get weird behaviour when I try rewriting init:

def __init__(self):
    super(theSuperClass, self).__init__()

TypeError: super(type, obj): obj must be an instance or subtype of type

Anyone have any idea how to do this?

© Stack Overflow or respective owner

Related posts about django