On Apr 21, 8:25 am, Torsten Bronger <bron...@physik.rwth-aachen.de>
wrote:
> Yes, but normally, you have tools like type(instance) or
> instance.__class__.  However, in Django, you don't.  That's the
> problem.

Sure you do...

>>> from website.blog.models import Entry
>>> e = Entry.objects.all()[0]
>>> e.__class__
<class 'website.blog.models.Entry'>
>>> type(e)
<class 'website.blog.models.Entry'>

>
> Besides, in Python,
>
> for instance in instances:
>     instance.do_something()
>
> calls the method of the respective class of "instance".  However, in
> Django,
>
> for instance in RootClass.objects.all():
>     instance.do_something()
>
> will *always* call RootClass.do_something(), which is almost never
> what you want.
>

I don't necessarily think that's a problem at all. That's the way it
should work. You want to be able to call RootClass.do_something() on
an instance of RootClass and have it run that method from one of the
sub classes?

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