from django.db import models
class UpperCaseCharField(models.CharField):

    def __init__(self, *args, **kwargs):
        super(UpperCaseCharField, self).__init__(*args, **kwargs)

    def pre_save(self, model_instance, add):
        value = getattr(model_instance, self.attname, None)
        if value:
            value = value.upper()
            setattr(model_instance, self.attname, value)
            return value
        else:
            return super(UpperCaseCharField, self).pre_save(model_instance, add)
			
class TitleCaseCharField(models.CharField):

    def __init__(self, *args, **kwargs):
        super(TitleCaseCharField, self).__init__(*args, **kwargs)

    def pre_save(self, model_instance, add):
        value = getattr(model_instance, self.attname, None)
        if value:
            value = value.title()
            setattr(model_instance, self.attname, value)
            return value
        else:
            return super(TitleCaseCharField, self).pre_save(model_instance, add)
