Changes between Version 1 and Version 8 of Ticket #32993
- Timestamp:
- Aug 8, 2021, 2:47:05 PM (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #32993
- Property Triage Stage Unreviewed → Accepted
- Property Version 3.2 → dev
- Property Type Cleanup/optimization → New feature
- Property Owner changed from to
- Property Status new → assigned
- Property Has patch set
-
Ticket #32993 – Description
v1 v8 51 51 return JsonResponse({ 52 52 'results': [ 53 self. obj_to_dict(obj, to_field_name) for obj in context['object_list']53 self.serialize_result(obj, to_field_name) for obj in context['object_list'] 54 54 ], 55 55 'pagination': {'more': context['page_obj'].has_next()}, … … 57 57 }}} 58 58 59 where {{{ obj_to_dict()}}} contains the original object to dictionary conversion code that would be now easy to override:59 where {{{serialize_result()}}} contains the original object to dictionary conversion code that would be now easy to override: 60 60 61 61 {{{#!python 62 def obj_to_dict(self, obj, to_field_name):62 def serialize_result(self, obj, to_field_name): 63 63 return {'id': str(getattr(obj, to_field_name)), 'text': str(obj)} 64 64 }}} … … 69 69 class CustomAutocompleteJsonView(AutocompleteJsonView): 70 70 71 def obj_to_dict(self, obj, to_field_name):72 return super. obj_to_dict(obj, to_field_name) | {'notes': obj.notes}71 def serialize_result(self, obj, to_field_name): 72 return super.serialize_result(obj, to_field_name) | {'notes': obj.notes} 73 73 }}} 74 74