I'm trying to style a field in my form using django-tinymce without success, as it just displays an ordinary CharField in the form. The test form is part of a formset rendered with Django crispy forms.
models.py
class test(models.Model)
test = models.CharField(max_length=100)
forms.py
from tinymce.widgets import TinyMCE
class TestForm(forms.ModelForm):
class Meta:
test = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
model = test
def __init__(self, *args, **kwargs):
super(TestForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_tag = False
self.helper.layout = layout.Layout(
layout.Fieldset(
_("Test"),
layout.Field("test"),
),
)
urls.py
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'tripller.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^tinymce/', include('tinymce.urls')),
)
template
{% load i18n crispy_forms_tags %}
<form method="post" action="." enctype="multipart/form-data">
{% csrf_token %}
{% crispy form %}
{{ formset.management_form }}
{{ formset.non_form_errors }}
{% for form in formset %}
{{ form.id }}
<div class="inline {{ formset.prefix }}">
{% crispy form %}
{{ form.description.errors }}
{{ form.description.label_tag }}
{{ form.description }}
</div>
{% endfor %}
</form>
settings.py
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ajaxuploader',
'crispy_forms',
'tinymce',
)
TINYMCE_JS_URL = os.path.join(STATIC_ROOT, "js/tiny_mce/tiny_mce.js")
TINYMCE_JS_ROOT = os.path.join(STATIC_ROOT, "js/tiny_mce")
TINYMCE_SPELLCHECKER = True
TINYMCE_COMPRESSOR = True
TINYMCE_DEFAULT_CONFIG = {
'theme': "advanced",
'plugins': "spellchecker",
'theme_advanced_buttons3_add': "|,spellchecker",
}
Is this the correct way of specifying the static files url, whereby all my js files are stored in the static folder instead of the media folder as suggested in the docs? Is the CharField not working due to the parameters defined incorrectly?
How can I specify a Textfield displayed using TinyMCE editor?
Assuming that a user finishes editing the form via TinyMCE, how can I display the submitted data as a html form?