Skip to content

Not able to work with django-rest #13

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

Closed
ghost opened this issue Jun 4, 2015 · 5 comments
Closed

Not able to work with django-rest #13

ghost opened this issue Jun 4, 2015 · 5 comments

Comments

@ghost
Copy link

ghost commented Jun 4, 2015

Hi, I am trying to encrypt the fields,

class BankDetails(models.Model):
    id              = models.AutoField(primary_key=True)
    bank_name       = EncryptedTextField()
    account_number  = EncryptedIntegerField()
    ifsc_code       = EncryptedIntegerField() 

I am using rest framework also, When I try to access the rest api, it throws an error TextField

Request Method: GET
Request URL: http://localhost.com:8000/bankdetails/

Django Version: 1.7.4
Python Version: 2.7.9
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'rest_framework',
 'rest_framework.authtoken',
 'app',
 'djcelery',
 'kombu.transport.django')
Installed Middleware:
(
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "C:\Users\YuO\project\www\lib\site-packages\django-1.7.4-py2.7.egg\django\core\handlers\base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\YuO\project\www\lib\site-packages\django-1.7.4-py2.7.egg\django\views\decorators\csrf.py" in wrapped_view
  57.         return view_func(*args, **kwargs)
File "C:\Users\YuO\project\www\lib\site-packages\django-1.7.4-py2.7.egg\django\views\generic\base.py" in view
  69.             return self.dispatch(request, *args, **kwargs)
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\views.py" in dispatch
  407.             response = self.handle_exception(exc)
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\views.py" in dispatch
  404.             response = handler(request, *args, **kwargs)
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\generics.py" in get
  311.         return self.list(request, *args, **kwargs)
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\mixins.py" in list
  46.         return Response(serializer.data)
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\serializers.py" in data
  615.         ret = super(ListSerializer, self).data
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\serializers.py" in data
  212.                 self._data = self.to_representation(self.instance)
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\serializers.py" in to_representation
  565.             self.child.to_representation(item) for item in iterable
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\serializers.py" in to_representation
  419.         fields = [field for field in self.fields.values() if not field.write_only]
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\serializers.py" in fields
  312.             for key, value in self.get_fields().items():
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\serializers.py" in get_fields
  1006.                 kwargs = get_field_kwargs(field_name, model_field)
File "C:\Users\YuO\project\www\lib\site-packages\djangorestframework-3.0.5-py2.7.egg\rest_framework\utils\field_mapping.py" in get_field_kwargs
  70.     validator_kwarg = list(model_field.validators)
File "C:\Users\YuO\project\www\lib\site-packages\django-1.7.4-py2.7.egg\django\utils\functional.py" in __get__
  55.         res = instance.__dict__[self.func.__name__] = self.func(instance)
File "C:\Users\YuO\project\www\lib\site-packages\django-1.7.4-py2.7.egg\django\db\models\fields\__init__.py" in validators
  1590.         min_value, max_value = connection.ops.integer_field_range(internal_type)
File "C:\Users\YuO\project\www\lib\site-packages\django-1.7.4-py2.7.egg\django\db\backends\__init__.py" in integer_field_range
  1334.         return self.integer_field_ranges[internal_type]

Exception Type: KeyError at /bankdetails/
Exception Value: 'TextField'

@LigorioSalgado
Copy link

You can resolve this??

@ghost
Copy link
Author

ghost commented Dec 8, 2015

I was not able to resolve it.

@defrex
Copy link
Owner

defrex commented Dec 10, 2015

Sorry I got busy and forgot about this. If you could create a simple case to reproduce the issue, it'd help me out a lot being able to debug it.

@mattijohn
Copy link

I think this was fixed on master with #7, but the version on pypi (1.1.1) doesn't seem to include the fix.

@defrex
Copy link
Owner

defrex commented Jan 29, 2016

I've just pushed the latest version to PyPi. Let me know if this issue persists.

@defrex defrex closed this as completed Jan 29, 2016
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

3 participants