Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"FIELD_ENCRYPTION_KEY must be defined in settings" - but it is defined in settings #27

Open
Jessica-Ryan opened this issue Feb 13, 2022 · 1 comment

Comments

@Jessica-Ryan
Copy link

  • 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?

@BrandenLY
Copy link

Hi, Jessica!

I'm not sure if you've resolved your issue or not yet, however you may find this documentation helpful.

Django Encrypted Model Fields Documentation

If this does not help address your issues, it may be helpful to include what you have in your settings.py file, as well as in your models.py file where you are attempting to use encrypted fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants