Changes between Version 18 and Version 19 of ModelInheritance
- Timestamp:
- Feb 27, 2006, 5:29:38 PM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
ModelInheritance
v18 v19 171 171 172 172 Thus, there is simply no 'name' field for it to inherit. So, we need to have ModelBase walk through the parent classes and call contribute_to_class on each of the fields found in _meta.fields. As we walk the inheritance tree, we look for a '_meta' attribute to determine if our current node is a Model. Otherwise, it is either a mixin class or the Model class iteself. 173 174 We can keep track of the parent hierarchy by creating _meta.parents, and having each ancestor of Model add to it in a recursive fasion, by adding the following to ModelBase.__new__(): 175 176 {{{ 177 new_class._meta.parents = bases 178 for base in bases: 179 if '_meta' in dir(base): 180 new_class._meta.parents.extend(base._meta.parents) 181 182 }}}