I want this field to be saved encrypted in the db, but appear unencrypted everywhere else:
class EncryptedCharField(models.CharField): __metaclass__ = models.SubfieldBase def save_form_data(self, instance, data): setattr(instance, self.name, encrypt(data)) #def get_prep_value(self, value): # return encrypt(data) def value_from_object(self, obj): return decrypt(getattr(obj, self.attname)) #def to_python(self, value): # return decrypt(value) class MyModel(models.Model): secret = EncryptedCharField(max_length=100) When this field is used in modelforms it works just fine: it is shown with its decrypted length and saved encrypted. However when secret is accessed, such as: object = MyModel.objects.get() -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.