pip install django-colorful
An Example:

from django.db import models
from colorful.fields import RGBColorField

class Tag(models.Model):
 color = RGBColorField()

You can add choices:
color = RGBColorField(colors=['#FF0000', '#00FF00', '#0000FF'])

 

In Wagtail you may need to give it some custom styling to be displayed correctly:

/opt/mysite/lib/python3.4/site-packages/wagtail/wagtailadmin/templates/wagtailadmin/pages/_editor_css.html

<style>
#id_color { height: 40px!important; width: 100px!important; padding: 0px!important;}
</style>
Advertisement