georgemarshall / django-cryptography

Easily encrypt data in Django
https://django-cryptography.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
382 stars 75 forks source link

IP address Encrypted #19

Closed tboulogne closed 4 years ago

tboulogne commented 5 years ago

Hello,

I face this issue

django.db.utils.ProgrammingError: cannot cast type inet to bytea
LINE 1: ...access" ALTER COLUMN "ac_ip" TYPE bytea USING "ac_ip"::bytea

When i try to encrypt an ipaddress field :

ac_ip = encrypt(models.GenericIPAddressField(
        verbose_name="IP", protocol='IPv4', blank=True, null=True))

Anyway to workaround this ?

Thanks for your help.

Regards,

Thierry

thismatters commented 5 years ago

Sorry for the delayed response, I hope you found a workaround to this! For any who encountering this problem for the first time... This seems like another one of those issues that can be fixed by making a new encrypted field, migrating the data to it, then deleting the old plaintext field, finally rename the new encrypted field to whatever the old field was named. It is the standard switcheroo required when encrypting a field.

georgemarshall commented 4 years ago

Information about encrypting a field can be found in https://github.com/georgemarshall/django-cryptography/issues/11