Hallöchen! Tim Shaffer writes:
> [...] > >>>> a = Author(first="Tim", last="Shaffer") >>>> a.translator = Translator(language="English") >>>> a.editor = Editor(language="German") > >>>> t = Translator.objects.all()[0] > > This works as I would expect it to... > >>>> a.do_something() > "I'm going to write" > >>>> t.do_something() > "I'm going to translate" > >>>> Author.do_something(t) > "I'm going to write" > > Calling a.do_something() should *never* call either > Translator.do_something() or Editor.do_something() You're right that this would contradict Django's documented behaviour, which is efficient and well-defined. However, it is not practical in presence of abstract base classes. Consider the following scenario: Author, Editor, and Translator are all derived from Person. No person actually is "Person". "Person" is simply the common base class. Then you want to list all contributors on a web page in a table. The first column is the name -- that simple, because it is an attribute. The second column is the result of "do_something()". This wouldn't work, because the dynamic binding doesn't work in Django: {% for person in persons %} <tr><td>{{ person.name }}</td><td>{{ person.do_something }}</td></tr> {% endfor %} My use case is somewhat different, by the way: I'd like to apply a specially-tailored template to the instance whose name is derived from the instance's model name. This doesn't work in vanilla Django. Mostly, though, you are only interested in the base class attributes, so Django's behaviour is okay. Additionally, fetching the actual instance for each instance is costly. The cleanest solution is a contenttype attribute which contains the actual model. Tschö, Torsten. -- Torsten Bronger, aquisgrana, europa vetus Jabber ID: torsten.bron...@jabber.rwth-aachen.de or http://bronger-jmp.appspot.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.