{"action":"created","issue":{"url":"https://api.github.com/repos/InterSIS/django-rest-encrypted-lookup/issues/14","repository_url":"https://api.github.com/repos/InterSIS/django-rest-encrypted-lookup","labels_url":"https://api.github.com/repos/InterSIS/django-rest-encrypted-lookup/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/InterSIS/django-rest-encrypted-lookup/issues/14/comments","events_url":"https://api.github.com/repos/InterSIS/django-rest-encrypted-lookup/issues/14/events","html_url":"https://github.com/InterSIS/django-rest-encrypted-lookup/issues/14","id":184655960,"number":14,"title":"using id with filter_class","user":{"login":"whoisearth","id":5064995,"avatar_url":"https://avatars.githubusercontent.com/u/5064995?v=3","gravatar_id":"","url":"https://api.github.com/users/whoisearth","html_url":"https://github.com/whoisearth","followers_url":"https://api.github.com/users/whoisearth/followers","following_url":"https://api.github.com/users/whoisearth/following{/other_user}","gists_url":"https://api.github.com/users/whoisearth/gists{/gist_id}","starred_url":"https://api.github.com/users/whoisearth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whoisearth/subscriptions","organizations_url":"https://api.github.com/users/whoisearth/orgs","repos_url":"https://api.github.com/users/whoisearth/repos","events_url":"https://api.github.com/users/whoisearth/events{/privacy}","received_events_url":"https://api.github.com/users/whoisearth/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/InterSIS/django-rest-encrypted-lookup/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-22T21:45:56Z","updated_at":"2016-10-22T23:00:38Z","closed_at":null,"body":"I'm attempting to use a django filter while continuing using the encrypted id.\r\n\r\nI can do this - \r\n\r\n`http://localhost:8000/api/v1/widget/?id=3`\r\n\r\nbut I can't do this - \r\n\r\n`http://localhost:8000/api/v1/widget/?id=zspnn6wva2rd47z44jo65bi6iy`\r\n\r\ndoing so generates the following error:\r\n\r\n`invalid literal for int() with base 10: 'zspnn6wva2rd47z44jo65bi6iy'`\r\n\r\nwhich makes sense because it's expecting an integer.\r\n\r\nI'm using django-filter like so:\r\n\r\n```\r\nclass WidgetFilter(django_filters.FilterSet):\r\n    id = django_filters.CharFilter(name='id', lookup_type='exact')\r\n    name = django_filters.CharFilter(name='username', lookup_type='exact')\r\n    list = django_filters.CharFilter(name='list__name', lookup_type='exact')\r\n\r\n    class Meta:\r\n        model = Widget\r\n        fields = ['id', 'username', 'list__name']\r\n```\r\n\r\nWhen I query the actual ID it does return the encrypted value and I can query like this:\r\n\r\n`http://localhost:8000/api/v1/widget/zspnn6wva2rd47z44jo65bi6iy/`"},"comment":{"url":"https://api.github.com/repos/InterSIS/django-rest-encrypted-lookup/issues/comments/255559117","html_url":"https://github.com/InterSIS/django-rest-encrypted-lookup/issues/14#issuecomment-255559117","issue_url":"https://api.github.com/repos/InterSIS/django-rest-encrypted-lookup/issues/14","id":255559117,"user":{"login":"JASchilz","id":6137968,"avatar_url":"https://avatars.githubusercontent.com/u/6137968?v=3","gravatar_id":"","url":"https://api.github.com/users/JASchilz","html_url":"https://github.com/JASchilz","followers_url":"https://api.github.com/users/JASchilz/followers","following_url":"https://api.github.com/users/JASchilz/following{/other_user}","gists_url":"https://api.github.com/users/JASchilz/gists{/gist_id}","starred_url":"https://api.github.com/users/JASchilz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JASchilz/subscriptions","organizations_url":"https://api.github.com/users/JASchilz/orgs","repos_url":"https://api.github.com/users/JASchilz/repos","events_url":"https://api.github.com/users/JASchilz/events{/privacy}","received_events_url":"https://api.github.com/users/JASchilz/received_events","type":"User","site_admin":false},"created_at":"2016-10-22T23:00:38Z","updated_at":"2016-10-22T23:00:38Z","body":"Understood! It's been a while since I've touched this, so I might be a little dusty.\r\n\r\nIf I'm seeing it correctly, there's a failure of the two plugins to work together as opposed to a failure of this plugin. It looks like DRF Encrypted Lookup lives above the ORM level; it lives at the serializer and view level. And my guess is that django-filter bypasses these and reaches directly into the ORM level. So I'll label the issue as an enhancement or a question.\r\n\r\nThe easiest thing for you to do might be to modify the ID as it comes in, inside your filter class. You could use the `get_cipher` method of your DRF Encrypted Lookup Serializer. Then you can use the cipher's `encode` and `decode` methods--see [utils.py](https://github.com/InterSIS/django-rest-encrypted-lookup/blob/master/rest_framework_encrypted_lookup/utils.py)--to turn `zspnn6wva2rd47z44jo65bi6iy` into `3`.\r\n\r\nIf it works, let me know the code! The django-filter library looks like one I might want to use.\r\n\r\n"}}
{"actor":{"display_login":"JASchilz"}}