Home » Javascript » javascript – How to use colorpicker in wagtail?

javascript – How to use colorpicker in wagtail?

Posted by: admin February 24, 2020 Leave a comment

Questions:

I want to make colorpicker in a wagtail. because I want to change text color. now I use spectrum, but I tried it not work.

When I choose the color and put text and I click publish in wagtail admin alert (This field is required.)

I don’t know problems and how to fix it.

Anyone else has other methods to use the colorpicker?

Thanks.

How to&Answers:
  1. install django-colorful

  2. follow the instructions to add a field, i.e.

.

from colorful.fields import RGBColorField

class MyWagtailPage(Page):
    color = RGBColorField(blank=True, null=True)
    ...rest of your fields

    # add to your field panels
    content_panels = Page.content_panels + [
        FieldPanel("color"),
        ...

and then magically you’ll should get a colorpicker popup when you click on the black box when editing your page in Wagtail.