I am trying to 'fake out' a model form and display data from 2 columns
in one field. I can do this by returning the 2 columns in the model's
__unicode__ method, but I want to apply styling to the data - I want
one column's data left justified and the other column's data right
justified. When I return this in the __unicode__ method:
return mark_safe('<div style="float: left">%s</div><div style="float:
right">%s</div>' % (self.name, self.group_by))
The HTML gets stripped out and I end up with just the data, e.g.:
<option value="1">12S target</option>
If I return the markup without the mark_safe, the HTML generated looks
like this:
<option value="1"><div style="float:
left">12S</div><div style="float:
right">target</div></option>
But what is displayed in the select box on the browser is:
<div style="float: left">12S</div><div style="float: right">target</div>
Does anyone know how I can do this?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CACwCsY7uh%2BWruXhaD5h8cxpfzHxGghEpFdxwyAahW%2Ba2qHEfjg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.