Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. class ColorField(models.CharField):
  2.    
  3.     description = "Stores a color value."
  4.  
  5.     __metaclass__ = models.SubfieldBase
  6.        
  7.     def __init__(self, *args, **kwargs):
  8.         kwargs['max_length'] = 10
  9.         super(ColorField, self).__init__(*args, **kwargs)
  10.  
  11.     def formfield(self, **kwargs):
  12.         kwargs['widget'] = ColorWidget
  13.         return super(ColorField, self).formfield(**kwargs)
  14.  
  15.  
  16. from south.modelsinspector import add_introspection_rules
  17. add_introspection_rules([], ["^dater\.models\.ColorField"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement