Basically, I need to use the User's password hash to encrypt some data via a custom model field. Check out the snippet I used here: Django Encryption.
I tried this:
class MyClass(models.Model): owner = models.ForeignKey(User) product_id = EncryptedCharField(max_length=255, user_field=owner) ................................................................................. def formfield(self, **kwargs): defaults = {'max_length': self.max_length, 'user_field': self.user_field} defaults.update(kwargs) return super(EncryptedCharField, self).formfield(**defaults))
But when I try to use user_field, I get a ForeignKey instance (of course!):
user_field = kwargs.get('user_field') cipher = user_field.password[:32]
Any help is appreciated!