- Python 3.8.10
- Django 4.0.2
- django-encrypted-model-fields: 0.6.1
I am using encrypted_model_fields to encrypt a model field. The field I am encrypting is a password used to access a user account for another app via an api.
According to the docs I need to import the module and then wrap the model field as follows:
Models.py
from encrypted_model_fields.fields import EncryptedCharField
account_password = EncryptedCharField(models.CharField(max_length=20, blank=True))
In addition to that I need to add a FIELD_ENCRYPTION_KEY to settings.py, which I have done, as per the docs.
Settings.py
FIELD_ENCRYPTION_KEY = os.environ.get('FIELD_ENCRYPTION_KEY')
I have also added 'encrypted_model_fields' to installed apps in settings.py and the encryption key to .env, which is in place of the placeholder below..env:
export FIELD_ENCRYPTION_KEY=my_encryption_key_place_holder
When I run makemigrations I receive the following error:
django.core.exceptions.ImproperlyConfigured: FIELD_ENCRYPTION_KEY must be defined in settings
I have defined it - so why is it not found?