Closed will-emmerson closed 6 years ago
This didn't work for me.
Unsure if it was after upgrading to Bootstrap 4 or using the form in the frontend (as opposed to the admin) but I couldn't get the form to save.
Also, I'm fairly green so could be completely unrelated!
Ended up using this subclassing via the commented blog post.
forms.py
"""
https://fosstack.com/how-to-set-up-tinymce-in-django-app/
"""
class TinyMCEWidget(TinyMCE):
def use_required_attribute(self, *args):
return False
...
class JobForm1(forms.ModelForm):
class Meta:
model = Job
fields = (
'name',
'company',
'description',
'urlapply',
'emailapply',
)
description = forms.CharField(widget=TinyMCEWidget(mce_attrs={'width': 800}))
...
I had a bug where a form field using HTMLField() wasn't submitting the changed value. I finally tracked it down to using form.serialize() to send form via ajax - this issue: https://stackoverflow.com/q/2122085
The solution was to use
tinyMCE.triggerSave();
before submitting. I realise this isn't an issue with django-tinymce4-lite but just wondering if it's worth noting in documentation? Or integrating solution from https://stackoverflow.com/a/24284938 to avoid the problem: