I found the way - allow_tags=True ! #models.py class Structure(models.Model): ... def __unicode__(self): return self.title
def titleWithOffset(self): deep=Structure.getDeep(self) result=deep*4*' ' + self.title return result titleWithOffset.allow_tags=True #admin.py class StructureAdmin(admin.ModelAdmin): list_display=('titleWithOffset',) admin.site.register(Structure, StructureAdmin) On Jan 1, 7:50 pm, Xia Kai(夏恺) <xia...@gmail.com> wrote: > 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.comhttp://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 * " " + self.title > > > def getDeep(self): > > ... > > > The result was: > > Level 1 > > Level 2 > > 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.