InterSIS / django-rest-encrypted-lookup

Replace Rest Framework's IntegerField pk or id lookups with encrypted strings.
GNU General Public License v3.0
27 stars 8 forks source link

ENCRYPTED_LOOKUP settings dictionary must include a 'secret_key' key #13

Closed whoisearth closed 8 years ago

whoisearth commented 8 years ago

I'm trying to use your module in my rest framework. See below, hoping someone can point to me why it's not working.

The following is in my settings.py

ENCRYPTED_LOOKUP = {
    'lookup_field_name': 'id',
    'secret_key': 'mysecretkey',
},

In my serializers.py I have the following -

from rest_framework_encrypted_lookup.serializers import EncryptedLookupModelSerializer

class WidgetSerializer(EncryptedLookupModelSerializer):

    class Meta:
        model=Widget
        fields = ('id', 'title', 'description', 'username', 'code', 'owner', 'list')

When trying to run I get the following traceback -

Traceback:
File "/opt/myproject_app/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  119.                 resolver_match = resolver.resolve(request.path_info)
File "/opt/myproject_app/lib/python2.7/site-packages/django/core/urlresolvers.py" in resolve
  365.             for pattern in self.url_patterns:
File "/opt/myproject_app/lib/python2.7/site-packages/django/core/urlresolvers.py" in url_patterns
  401.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/opt/myproject_app/lib/python2.7/site-packages/django/core/urlresolvers.py" in urlconf_module
  395.             self._urlconf_module = import_module(self.urlconf_name)
File "/usr/local/lib/python2.7/importlib/__init__.py" in import_module
  37.     __import__(name)
File "/opt/myproject/myproject/urls.py" in <module>
  20. from gui import views
File "/opt/myproject/gui/views.py" in <module>
  20. from api.serializers import *
File "/opt/myproject/api/serializers.py" in <module>
  4. from rest_framework_encrypted_lookup.serializers import EncryptedLookupModelSerializer, EncryptedLookupHyperlinkedModelSerializer
File "/opt/myproject_app/lib/python2.7/site-packages/rest_framework_encrypted_lookup/serializers.py" in <module>
  8. from .settings import encrypted_lookup_settings
File "/opt/myproject_app/lib/python2.7/site-packages/rest_framework_encrypted_lookup/settings.py" in <module>
  23.                 "ENCRYPTED_LOOKUP settings dictionary must include a '%s' key." % required_key

Exception Type: AttributeError at /api/widgets/20/
Exception Value: ENCRYPTED_LOOKUP settings dictionary must include a 'secret_key' key.

As shown above the secret key is there.

JASchilz commented 8 years ago

Acknowledged! Will look into it tomorrow.

JASchilz commented 8 years ago

I think I got it. Documentation error on my part. Try removing the terminal comma on your ENCRYPTED_LOOKUP = {...},

JASchilz commented 8 years ago

Presumed resolved. Feel free to re-open.

whoisearth commented 8 years ago

yup it worked thanks again!