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
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
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
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
4 matches
Mail list logo