Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Cant run any correspondent query against documents api #412

Closed
thepill opened this issue Sep 23, 2018 · 2 comments
Closed

Cant run any correspondent query against documents api #412

thepill opened this issue Sep 23, 2018 · 2 comments

Comments

@thepill
Copy link

thepill commented Sep 23, 2018

All querys fail with the following error:

Environment:


Request Method: GET
Request URL: http://paperless/api/documents/?title__startswith=&title__endswith=&title__contains=&title__istartswith=&title__iendswith=&title__icontains=&content__contains=&content__icontains=&correspondent__name=test&correspondent__slug=&tags__name=&tags__slug=&tags__empty=

Django Version: 2.0.8
Python Version: 3.6.6
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'corsheaders',
 'django_extensions',
 'documents.apps.DocumentsConfig',
 'reminders.apps.RemindersConfig',
 'paperless_tesseract.apps.PaperlessTesseractConfig',
 'paperless_text.apps.PaperlessTextConfig',
 'django.contrib.admin',
 'rest_framework',
 'crispy_forms',
 'django_filters']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/root/.local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  35.             response = get_response(request)

File "/root/.local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  128.                 response = self.process_exception_by_middleware(e, request)

File "/root/.local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/root/.local/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
  54.         return view_func(*args, **kwargs)

File "/root/.local/lib/python3.6/site-packages/rest_framework/viewsets.py" in view
  103.             return self.dispatch(request, *args, **kwargs)

File "/root/.local/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
  483.             response = self.handle_exception(exc)

File "/root/.local/lib/python3.6/site-packages/rest_framework/views.py" in handle_exception
  443.             self.raise_uncaught_exception(exc)

File "/root/.local/lib/python3.6/site-packages/rest_framework/views.py" in dispatch
  480.             response = handler(request, *args, **kwargs)

File "/root/.local/lib/python3.6/site-packages/rest_framework/mixins.py" in list
  40.         queryset = self.filter_queryset(self.get_queryset())

File "/root/.local/lib/python3.6/site-packages/rest_framework/generics.py" in filter_queryset
  152.             queryset = backend().filter_queryset(self.request, queryset, self)

File "/root/.local/lib/python3.6/site-packages/django_filters/rest_framework/backends.py" in filter_queryset
  96.         return filterset.qs

File "/root/.local/lib/python3.6/site-packages/django_filters/filterset.py" in qs
  237.                 qs = self.filter_queryset(qs)

File "/root/.local/lib/python3.6/site-packages/django_filters/filterset.py" in filter_queryset
  224.             queryset = self.filters[name].filter(queryset, value)

File "/root/.local/lib/python3.6/site-packages/django_filters/filters.py" in filter
  147.         qs = self.get_method(qs)(**{lookup: value})

File "/root/.local/lib/python3.6/site-packages/django/db/models/query.py" in filter
  836.         return self._filter_or_exclude(False, *args, **kwargs)

File "/root/.local/lib/python3.6/site-packages/django/db/models/query.py" in _filter_or_exclude
  854.             clone.query.add_q(Q(*args, **kwargs))

File "/root/.local/lib/python3.6/site-packages/django/db/models/sql/query.py" in add_q
  1253.         clause, _ = self._add_q(q_object, self.used_aliases)

File "/root/.local/lib/python3.6/site-packages/django/db/models/sql/query.py" in _add_q
  1277.                     split_subq=split_subq,

File "/root/.local/lib/python3.6/site-packages/django/db/models/sql/query.py" in build_filter
  1215.         condition = self.build_lookup(lookups, col, value)

File "/root/.local/lib/python3.6/site-packages/django/db/models/sql/query.py" in build_lookup
  1079.             lhs = self.try_transform(lhs, lookup_name)

File "/root/.local/lib/python3.6/site-packages/django/db/models/sql/query.py" in try_transform
  1115.                 (name, lhs.output_field.__class__.__name__))

Exception Type: FieldError at /api/documents/
Exception Value: Unsupported lookup '('startswith', 'endswith', 'contains', 'istartswith', 'iendswith', 'icontains')' for CharField or join on the field not permitted.

@thepill thepill changed the title Cant run any filtered query against documents api Cant run any correspondent query against documents api Sep 23, 2018
@danielquinn
Copy link
Collaborator

I see the problem. It's flaking out on filtering for correspondent name (a join) but not on attributes like title or content. I'm looking into it now.

@danielquinn
Copy link
Collaborator

It turns out that when we updated django-filter a while back that its API changed and no one noticed that that change broke Paperless' own stuff until you posted this, so thanks! It should be all fixed now, so give it a try.

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

No branches or pull requests

2 participants