Re: get an object's model name

2009-08-27 Thread MIL
Thanks, both of you :o) I tried using it directly in my template like {{object.__class__.__name__}} But that didnt work. So I did it by adding this to my models: def get_model_name(self): return self.__class__.__name__ And it works Thanks again :o) On 27 Aug., 13

Re: get an object's model name

2009-08-27 Thread David Zhou
On Thu, Aug 27, 2009 at 7:08 AM, Léon Dignòn wrote: > from django.contrib.auth.models import User u = User.objects.get(id=1) u > print u > leon type(u) > Alternatively: >>> u.__class__.__name__ 'User' -- dz --~--~-~--~~~---~--~~ You re

Re: get an object's model name

2009-08-27 Thread Léon Dignòn
Hello, simply use type() >>> from django.contrib.auth.models import User >>> u = User.objects.get(id=1) >>> u >>> print u leon >>> type(u) -ld On Aug 27, 11:59 am, MIL wrote: > Hello :o) > > I would like to know how to get the model name of an object. > > sort of like object.get_model_name

get an object's model name

2009-08-27 Thread MIL
Hello :o) I would like to know how to get the model name of an object. sort of like object.get_model_name or something like that Is there a way to that. I tried altering my model something like this, but it doesnt work: def get_model_name(self): return '%s'%(class) T