defrex / django-encrypted-fields

This is a collection of Django Model Field classes that are encrypted using Keyczar.
MIT License
193 stars 60 forks source link

EncryptedDecimalField Django 1.7 #9

Closed davideferre closed 8 years ago

davideferre commented 9 years ago

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!

defrex commented 9 years ago

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.

davideferre commented 9 years ago

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?

defrex commented 9 years ago

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?

davideferre commented 9 years ago

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!

defrex commented 9 years ago

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.