On Wed, Apr 21, 2010 at 19:33, Daniel Roseman <dan...@roseman.org.uk> wrote:
>>
>> Any tips?
>
> This is the expected behaviour. You've asked for an Author object, so
> that's what you've got. There's no way to tell from the Author model
> that this particular instance of it is also an instance of Translator.

I presume this will make you all wince, but while appreciating the
discussion I've caused I've solved it thusly:
------------------------
views.py
def index(request):
 all_authors = Author.objects.all()
 all_origAuthors = []
 all_translators = Translators.objects.all()
 for author in all_authors:
   if author in all_translators:
     pass
   else:
     all_origAuthors.append(author)
 return render_to_response('books/index.html',locals())
------------------------

That nested loop is pretty inefficient, but it's a low visit site and
it shouldn't matter too much.

The other piece of advice I got was that I should have created a
second subclass:

class Author(Models.model) - this class _could_ be abstracted in this change.

class Writer(Author) - the Original Author
class Translator(Author)

Whether Author is abstract or not, we don't create any Author objects
directly, only Writer and Translator. Then it's easier :)

cheers
L.

-- 
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.

Reply via email to