2đź‘Ť
âś…
It’s not Django doing this, its the browser “normalizing” what it sees as invalid markup. According to HTML spec, <p>
tags can’t contain <ul>
tags:
List elements (in particular, ol and ul elements) cannot be children
of p elements.
The spec recommends either closing the paragraph before staring the list: <p>...</p><ul>...</ul><p>...</p>
(which is exactly what the browser did) or to use <div>
instead of <p>
.
To test, try downloading the page using wget
and opening in a text editor – you’ll see that the generated markup is what you told Django to render, no extra tags added.
👤Sergey
Source:stackexchange.com