Geotrek-admin
Geotrek-admin copied to clipboard
Ordering by city is broken on Infrastructures page
Description
On Geotrek Admin list of Infrastructures (Aménagements) page clicking the arrows to order the list by city does not work and a Datatables error message is shown in a popup.
Reproduced on Geotrek Admin demo v2.102.1.
More info
Error message on Geotrek Admin interface :
DataTables warning: table id=objects-list - Ajax error. For more information about this error, please see http://datatables.net/tn/7
Corresponding error stacktrace:
FieldError: Cannot resolve keyword 'cities' into field. Choices are: access, access_id, accessibility, accessibility_en, accessibility_es, accessibility_fr, accessibility_it, aggregations, ascent, attachments, blades_set, condition, condition_id, date_insert, date_update, deleted, descent, description, description_en, description_es, description_fr, description_it, eid, geom, geom_3d, geom_need_update, id, implantation_year, kind, length, maintenance_difficulty, maintenance_difficulty_id, max_elevation, min_elevation, name, name_en, name_es, name_fr, name_it, offset, provider, publication_date, published, published_en, published_es, published_fr, published_it, slope, structure, structure_id, topo_object, topo_object_id, type, type_id, usage_difficulty, usage_difficulty_id, uuid
File "django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "rest_framework/viewsets.py", line 125, in view
return self.dispatch(request, *args, **kwargs)
File "rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "mapentity/decorators.py", line 75, in _wrapped_view
return view_func(self, request, *args, **kwargs)
File "mapentity/decorators.py", line 100, in _wrapped_method
return view_func(self, *args, **kwargs)
File "mapentity/views/api.py", line 86, in list
return super().list(request, *args, **kwargs)
File "rest_framework/mixins.py", line 38, in list
queryset = self.filter_queryset(self.get_queryset())
File "rest_framework/generics.py", line 150, in filter_queryset
queryset = backend().filter_queryset(self.request, queryset, self)
File "rest_framework_datatables/filters.py", line 194, in filter_queryset
queryset = queryset.order_by(*ordering)
File "modeltranslation/manager.py", line 351, in order_by
return super().order_by(*new_args)
File "django/db/models/query.py", line 1149, in order_by
obj.query.add_ordering(*field_names)
File "django/db/models/sql/query.py", line 2016, in add_ordering
self.names_to_path(item.split(LOOKUP_SEP), self.model._meta)
File "django/db/models/sql/query.py", line 1562, in names_to_path
raise FieldError("Cannot resolve keyword '%s' into field. "
as it's a simple texte field, we just need to disable the order on this