Changes between Version 1 and Version 8 of Ticket #32993


Ignore:
Timestamp:
Aug 8, 2021, 2:47:05 PM (3 years ago)
Author:
mrts
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #32993

    • Property Triage Stage UnreviewedAccepted
    • Property Version 3.2dev
    • Property Type Cleanup/optimizationNew feature
    • Property Owner changed from nobody to mrts
    • Property Status newassigned
    • Property Has patch set
  • Ticket #32993 – Description

    v1 v8  
    5151        return JsonResponse({
    5252            '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']
    5454            ],
    5555            'pagination': {'more': context['page_obj'].has_next()},
     
    5757}}}
    5858
    59 where {{{obj_to_dict()}}} contains the original object to dictionary conversion code that would be now easy to override:
     59where {{{serialize_result()}}} contains the original object to dictionary conversion code that would be now easy to override:
    6060
    6161{{{#!python
    62 def obj_to_dict(self, obj, to_field_name):
     62def serialize_result(self, obj, to_field_name):
    6363    return {'id': str(getattr(obj, to_field_name)), 'text': str(obj)}
    6464}}}
     
    6969class CustomAutocompleteJsonView(AutocompleteJsonView):
    7070
    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}
    7373}}}
    7474
Back to Top