Flask-Admin is a well-known extension for Flask which allows to add handy admin interface to Flask-based applications. It was inspired by the django-admin package. It’s distinguishing features are high customization capabilities. The developer can extend and customize it to implement any necessary functionality without problems.

In this post, we will show how to create and use custom editors for some properties of your models. For example, let’s create WYSIWYG editor instead of standard HTML textarea field.

There is StackOverflow post which provides short instructions to do that. But we have found this way bit more complex than it is necessary. So, let’s take a look at our solution.

For example, we have the next SQLAlchemy model:

Now we want to use CKEditor for editing description property of our model. In order to do that let’s create subclass of standard ModelView: In the second line we’ve specified that our textarea will have the next two classes: 'form-control, ckeditor'. ckeditor class is used by the library to detect which exactly fields should be replaced with rich HTML editor. In the last two lines we have added our custom template which is necessary to enalbe CKEditor JS library: