Hi,

Strange question you have there, why would you like to put html code in 
model's __unicode__ method at all?

I personally would only construct the __unicode__ method to display a model 
instance's information, which is meant to be shown on the commandline. As to 
html code, that is in the realm of Template, which is way too far from the 
Model(usually we have View in between).

As html code would only make sense when it is displayed on a webpage, so 
maybe you could try some filter(safe) to allow your html code to be passed 
to the html without being transformed.
------------------------
Xia Kai(夏恺)
xia...@gmail.com
http://blog.xiaket.org

--------------------------------------------------
From: "ev" <evpozdnia...@gmail.com>
Sent: Saturday, January 02, 2010 12:35 AM
To: "Django users" <django-users@googlegroups.com>
Subject: how to put html in __unicode__() ?

> I tryed to do:
>
> class Structure(models.Model):
> ....
>
> def __unicode__(self):
> deep = Structure.getDeep(self)
> return deep * "&nbsp;" + self.title
>
> def getDeep(self):
> ...
>
> The result was:
> Level 1
> &nbsp;Level 2
> &nbsp;&nbsp;Level 3
> etc
>
> So, how to put html entities in __unicode__() ? 

--

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