pydanny / django-wysiwyg

A Django application for making Django textareas rich text editors. Certainly as a template tag and possibly as a form widget.
http://django-wysiwyg.readthedocs.org
MIT License
465 stars 63 forks source link

Error "This field is required" only when using WYSIWYG on field #60

Open Morrolan opened 7 years ago

Morrolan commented 7 years ago

When using a normal TextField without django-wysiwyg, I can save my form perfectly fine, but when using django-wysiwyg I get an error "This field is required" on the TextField I want to use the WYSIWYG on. This does not make a difference if I change editor.

{% extends "base.html" %}

    {% block content %}

        {% load wysiwyg %}
        {% wysiwyg_setup %}

        <div class="ui header">Create New Post</div>

        <form method='POST' action='{% url "bpcpost:new_post" %}' enctype='multipart/form-data'>
            {% csrf_token %}
            <table class="ui celled striped red table">
                {{ form.as_table }}
            </table>
            <input type='submit' class='ui red button' value='Save'/>
        </form>

        {% wysiwyg_editor "wysiwyg_content" %}

    {% endblock content %}

My model is very simple:

class Post(models.Model):
    title = models.CharField(max_length=50)
    content = models.TextField(max_length=5000)
    slug = models.SlugField(unique=True)
    author = models.ForeignKey(settings.AUTH_USER_MODEL, default=1)
    draft = models.BooleanField(default=False)
egoag commented 7 years ago

I had the same error, when I specify widget=forms.Textarea on the wysiwyg field, the error is gone.

Morrolan commented 7 years ago

Many thanks for the response, I'll try it out. I switched to directly using ckeditor in the meantime but I prefer the flexibility of django-wysiwyg.