On Tue, Jan 21, 2014 at 8:53 AM, Bill Freeman <ke1g.nh@gmail.com> wrote:
> Have you confirmed that it isn't the browser doing this?
>
> That is, with the mark safe in place, have you looked at the output with
> curl?
>
> Or have you made a static html page with the desired construct in it, and
> viewed it in the browser?
>
> It may bee that option elements can't contain block level elements. You
> could see what you can do with span instead of div.
I discovered that <option> elements only allow "text with eventually
escaped characters (like é).", not general HTML -
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option.
> On Sun, Jan 19, 2014 at 6:50 PM, Larry Martell <larry.martell@gmail.com>
> wrote:
>>
>> 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 django-users+unsubscribe@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> 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.
>
>
> --
> 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 django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> 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/CAB%2BAj0s8mRHEnu5uv%3Dz21ErKeR2t3MaSk%2Bx08Mo%2BKz2yokcO0Q%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.
--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CACwCsY71YUjJSr%3DDJsqZHpAXAQaaedOjhjmUOBrTq2HrdDSXSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment