I'm trying to use flask_ckeditor in my flask project. I followed the doc but keep getting this error: Uncaught ReferenceError: CKEDITOR is not defined (in browser console).
Here is my form:
class AdminUserCreateCKForm(FlaskForm):
username = StringField('Username', validators=[DataRequired()])
email = EmailField('Email', validators=[DataRequired()])
pwdhash = PasswordField('Password', validators=[DataRequired()])
admin = BooleanField('Admin')
content = CKEditorField('Content')
submit = SubmitField('Submit')
My template:
{% extends "base.html" %}
{% block content %}
<div style="padding-top: 50px; padding-right: 50px;">
<form action="{{ url_for('auth.admin.user_create_ck') }}" method="post">
{{ form.csrf_token }}
{{ render_field(form.username) }}
{{ render_field(form.email) }}
{{ render_field(form.pwdhash) }}
{{ render_field(form.admin) }}
{{ form.content() }}
{{ render_field(form.submit) }}
</form>
{{ ckeditor.load(custom_url=url_for('static', filename='ckeditor/ckeditor.js')) }}
{{ ckeditor.config(name='content') }}
</div>
{% endblock %}
Trying to serve ckeditor.js from local, so here is my application factory:
# ...some stuff
ckeditor = CKEditor()
def create_app(config_class=Config):
app = Flask(__name__, static_url_path='/static')
app.config.from_object(config_class)
app.config['CKEDITOR_SERVE_LOCAL'] = True
# the rest of the stuff...
Every other field in the form, render without issue. But for 'content' i only get a simple textarea. Did try to load ckeditor in my base.html with a script tag. Did not work. (bootstrap loads fine. So i think my static folder is accessed properly.)
I was able to fix the problem by replacing the ckeditor.js file with the entire version 4 (ready-to-use) standard package. Note: LTS does not work.