Files
app-store-optimization/skills/loki-mode/benchmarks/results/2026-01-05-10-37-54/swebench-loki-patches/django__django-14752.patch

32 lines
1.3 KiB
Diff

# django__django-14752
# Loki Mode Multi-Agent Patch
# Attempts: 1
Based on the issue description and the architect's analysis, I need to generate a patch for Django's `AutocompleteJsonView` class. The issue provides the current implementation details, so I can create the patch based on that information.
--- a/django/contrib/admin/views/autocomplete.py
+++ b/django/contrib/admin/views/autocomplete.py
@@ -26,12 +26,21 @@ class AutocompleteJsonView(BaseListView):
raise PermissionDenied
self.object_list = self.get_queryset()
context = self.get_context_data()
return JsonResponse({
'results': [
- {'id': str(getattr(obj, to_field_name)), 'text': str(obj)}
- for obj in context['object_list']
+ self.serialize_result(obj, to_field_name)
+ for obj in context['object_list']
],
'pagination': {'more': context['page_obj'].has_next()},
})
+ def serialize_result(self, obj, to_field_name):
+ """
+ Convert the provided model object to a dictionary that is added to the
+ results list.
+ """
+ return {'id': str(getattr(obj, to_field_name)), 'text': str(obj)}
+
def get_paginator(self, *args, **kwargs):
"""Use the ModelAdmin's paginator."""