Repository: akvo/akvo-rsr

Issue:
Unable to fetch project updates in Up app
The current UAT build for the 3.13 release breaks the project updates download when Up data is loaded or refreshed:

https://github.com/akvo/akvo-rsr-up/issues/186

Environment:

Request Method: GET
Request URL: http://rsr.uat.akvo.org/rest/v1/project_up/2210/?format=xml&image_thumb_name=up&image_thumb_up_width=100

Django Version: 1.7.7
Python Version: 2.7.3
Installed Applications:
('nested_inline',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.humanize',
'django.contrib.messages',
'django.contrib.sessions',
'django.contrib.staticfiles',
'django.contrib.webdesign',
'akvo.codelists',
'akvo.rsr',
'akvo.api',
'registration',
'template_utils',
'paypal.standard.ipn',
'sorl.thumbnail',
'django_counter',
'mollie.ideal',
'django_sorting',
'pagination',
'embed_video',
'django_markup',
'django_filters',
'tastypie',
'rest_framework',
'rest_framework.authtoken',
'rest_framework_swagger',
'pipeline',
'bootstrap3',
'rules',
'django_crontab',
'raven.contrib.django.raven_compat')
Installed Middleware:
('akvo.rsr.middleware.HostDispatchMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.http.ConditionalGetMiddleware',
'django_sorting.middleware.SortingMiddleware',
'pagination.middleware.PaginationMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'akvo.rsr.middleware.ExceptionLoggingMiddleware',
'akvo.rsr.middleware.RSRVersionHeaderMiddleware',
'django_statsd.middleware.GraphiteRequestTimingMiddleware',
'django_statsd.middleware.GraphiteMiddleware',
'django_statsd.middleware.TastyPieRequestTimingMiddleware')

Traceback:
File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response

response = wrapped_callback(request, callback_args, _callback_kwargs) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/rest_framework/viewsets.py" in view
return self.dispatch(request, args, *kwargs) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
return view_func(args, *kwargs) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/rest_framework/views.py" in dispatch
response = self.handle_exception(exc) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/rest_framework/views.py" in dispatch
response = handler(request, args, *kwargs) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/rest_framework/mixins.py" in retrieve
self.object = self.get_object() File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/rest_framework/generics.py" in get_object
queryset = self.filter_queryset(self.get_queryset()) File "/var/akvo/rsr/code/akvo/rest/views/project.py" in get_queryset
return super(ProjectViewSet, self).get_queryset() File "/var/akvo/rsr/code/akvo/rest/viewsets.py" in get_queryset
queryset = super(PublicProjectViewSet, self).get_queryset() File "/var/akvo/rsr/code/akvo/rest/viewsets.py" in get_queryset
queryset = queryset.filter(_*lookup) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/django/db/models/query.py" in filter
return self._filter_or_exclude(False, args, *kwargs) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/django/db/models/query.py" in _filter_or_exclude
clone.query.add_q(Q(args, *kwargs)) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in add_q
clause, require_inner = self._add_q(where_part, self.used_aliases) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in _add_q
current_negated=current_negated, connector=connector) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in build_filter
lookups, parts, reffed_aggregate = self.solve_lookup_type(arg) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in solve_lookup_type
_, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta()) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in names_to_path
self.raise_field_error(opts, name) File "/var/akvo/rsr/versions/deploy-RSR_Deploy-251/venv/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in raise_field_error
"Choices are: %s" % (name, ", ".join(available)))
Exception Type: FieldError at /rest/v1/project_up/2210/
Exception Value: Cannot resolve keyword u'image_thumb_name' into field. Choices are: background, benchmarks, budget, budget_items, capital_spend_percentage, categories, collaboration_type, comments, conditions, contacts, country_budget_items, country_budget_vocabulary, created_at, crsadd, currency, current_image, current_image_caption, current_image_credit, current_status, custom_fields, date_end_actual, date_end_planned, date_start_actual, date_start_planned, default_aid_type, default_finance_type, default_flow_type, default_tied_status, documents, donate_button, fss, funds, funds_needed, goals, goals_overview, hierarchy, humanitarian, humanitarian_scopes, iati_activity_id, iati_checks, iati_project_exports, iati_project_import_logs, iati_project_imports, iatiexport, iatiimportjob, id, invoices, is_impact_project, is_public, keywords, language, last_modified_at, last_update, last_update_id, legacy_data, links, locations, notes, partners, partnerships, paymentgatewayselector, planned_disbursements, policy_markers, primary_location, primary_location_id, primary_organisation, primary_organisation_id, project_plan, project_plan_summary, project_scope, project_updates, publishingstatus, recipient_countries, recipient_regions, related_projects, related_to_projects, results, sectors, status, subtitle, sustainability, target_group, title, transactions, validations



Discussion:

Resolving patch:
diff --git a/akvo/rest/viewsets.py b/akvo/rest/viewsets.py
--- a/akvo/rest/viewsets.py
+++ b/akvo/rest/viewsets.py
@@ -44,10 +44,10 @@ def django_filter_filters(request):
             qs_params = ['filter', 'exclude', 'select_related', 'prefetch_related', ]
             # query string keys used by core DRF, OrderingFilter and Akvo custom views
             exclude_params = ['limit', 'format', 'page', 'ordering', 'partner_type', 'sync_owner',
-                              'reporting_org']
+                              'reporting_org', ]
             filters = {}
             for key in request.QUERY_PARAMS.keys():
-                if key not in qs_params + exclude_params:
+                if key not in qs_params + exclude_params and not key.startswith('image_thumb_'):
                     filters.update({key: request.QUERY_PARAMS.get(key)})
             return filters
 


Test patch: