defrex/django-encrypted-fields

EncryptedDecimalField Django 1.7

davideferre opened this issue · 5 comments

Hi!
I've created my custom EncryptedDecimalField following your readme, so in my utils.py file I've wrote this:

from django.db import models
from encrypted_fields import EncryptedFieldMixin

class EncryptedDecimalField(EncryptedFieldMixin, models.DecimalField):
    pass

Then in my model I've declared an original DecimalField as EncryptedDecimalField but values in db seems not changes. What's going wrong in my code?
Thanks in advance!

When you say the values in the database have not changed, what do you mean? Altering the field won't update the existing fields in the database. If the issue is that new values being stored in the database aren't being stored encrypted, I'd love to see more code. What you have here should work fine.

Exactly, when I store a value into the database, I can see it like a DecimalField, not encrypted.. I've have to write code for encrypting it?

You shouldn't. If you take a look at the test file for the project you can see that there are a bunch of tests ensuring that the various fields are stored encrypted. Can you write a test case that demonstrates the issue?

I have to learn how to write tests... ;)
I'm using sqlite db and after migrations I modified a record and I created a new one but both have EncryptedDecimalField wrote with the same value I have entered, not the same for EncryptedCharField for example.... So the encryption with standard fields works, but it doesn't work with my custom field.
Anyway I try to write a test as soon as possible ;).
Thanks!

If you're not conformable submitting a test, you could create a small Django project that does nothing but demonstrate the issue and upload that to github. That way I would have something to work with when trying to replicate the issue.