fields.py 391 B

12345678910111213
  1. from django.db import models
  2. from coderedcms.widgets import ColorPickerWidget
  3. class ColorField(models.CharField):
  4. def __init__(self, *args, **kwargs):
  5. kwargs['max_length'] = 255
  6. super(ColorField, self).__init__(*args, **kwargs)
  7. def formfield(self, **kwargs):
  8. kwargs['widget'] = ColorPickerWidget
  9. return super(ColorField, self).formfield(**kwargs)