Reputation: 41
My problem is that the RichTextField is the only field not displayed in the form.
I have a Model:
class RealestateObject(models.Model):
title = models.CharField(
max_length=256,
verbose_name=_('Object Title'),
)
summary = RichTextField(
verbose_name=_('Summary'),
blank=True, null=True,
)
description = models.TextField(
verbose_name=_('Description'),
blank=True, null=True,
)
And a form:
class RealestateObjectForm(forms.ModelForm):
class Meta:
model = TestRealestateObject
fields = ('title',
'summary',
'description'
)
and my template:
<form method="POST" action="">
{% csrf_token %}
{{ form }}
<button type="submit">Insert</button>
</form>
the title and description field are displayed in the form, the summary not. Is there a solution for this and/or a work around? I can't use the Wagtail Form Builder. It also would be great if I could use the richtext editor.
thanks.
Upvotes: 2
Views: 1518
Reputation: 25227
RichTextField
depends on some additional Javascript and CSS which is defined through Django form media. You need to add the following to your template (preferably within the HTML <head>
section):
{{ form.media.js }}
{{ form.media.css }}
Bear in mind that RichTextField
is primarily designed for use within the Wagtail admin interface, and some of its functionality (especially the popup link/image choosers) may well depend on other JS/CSS from there - disabling these features through the features
argument is one option for dealing with that.
Upvotes: 2