Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RichTextField - creates <p> ... </p>

Tags:

wagtail

(wagtail 1.9) I created a RichTextField (role in class person) and a FieldPanel for this field. In the template is {{ person.role }} . wagtail generates "<p>the role text</p>".

When does wagtail create <p> ... </p> for a RichTextField?

like image 922
egonFrerich Avatar asked Oct 12 '25 02:10

egonFrerich


1 Answers

You should use the |richtext filter when outputting rich text content in templates:

{% load wagtailadmin_tags %}

...
   {{ person.role|richtext }}

(This is necessary because rich text data is stored internally as a non-HTML format, which preserves references to other Wagtail pages and objects, e.g. <a linktype="page" id="123">some other page</a>. The |richtext filter converts this to "true" HTML.)

like image 83
gasman Avatar answered Oct 16 '25 07:10

gasman