views:

159

answers:

1

I have a Django project whereby every model inherits from a common "Object" model - which defines only two fields - the ID of the object (so every object in the entire system has a unique identifier) and a "type". The type is the type of object that particular instance is. This is a sort of "denormalized" field, making it faster to travel down the tree from Object to Person, for example.

Basically I have a field in one of the inherited models, which has the same name as another class that inherits from Object - that means that the field for travelling down the relationship is overridden.

I just wondered if anyone else has had a similar experience, and whether there are any rather elegant ways of solving it - other than just renaming the field in the inherited model.

+1  A: 

Maybe renaming would be appropriate. If one of your fields has the same identifier as a class, you may break some naming conventions (although, of course these are only conventions).

See PEP 8, section Naming Conventions.

Class Names

  Almost without exception, class names use the CapWords convention.
  Classes for internal use have a leading underscore in addition.


Method Names and Instance Variables

  Use the function naming rules: lowercase with words separated by
  underscores as necessary to improve readability.
The MYYN