On Thu, 2008-12-11 at 18:42 -0800, SliceOf314 wrote:
> I was just wondering why fields.RelatedField doesn't subclass
> models.Field?

Most likely just historical reasons.

> The comment for RelatedField is that it's a hack, and from what I can
> see RelatedField doesn't override any of Field's functionatliy.
> 
> This way, fields.ManyToMany and fields.ForeignKey wouldn't have to use
> multiple inheritance.

Sure, but it doesn't matter that they do use multiple inheritance. Think
of RelatedField is being used as a mixin, if you like. Sometimes when
stuff like this is written initially, it's easier to think of the added
functionality as going in via a mixin class than adding an extra layer
to the inheritance hierarchy.

Some people seem to dislike model inheritance because they've managed to
get into tangles in the past or read that it's evil or something. But
it's a valid programming tools and like all power tools, it can be both
used and abused. I have no personal knowledge of why the original code
is like that, but I don't see that multi-inheritance situation as being
any kind of problem.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to