Friday, January 1, 2010

Re: how to put html in __unicode__() ?

I just wanted to change standard admin page view with model elements.
Now I understand, that I should find another way to achieve my goal.

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 * "&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-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate