Python rest_framework.fields.DictField() Examples
The following are 2
code examples of rest_framework.fields.DictField().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
rest_framework.fields
, or try the search function
.
Example #1
Source File: serializers.py From course-discovery with GNU Affero General Public License v3.0 | 6 votes |
def get_fields(self): """ Return the field_mapping needed for serializing the data.""" # Re-implement the logic from the superclass methods, but make sure to handle field and query facets properly. # https://github.com/edx/course-discovery/blob/master/course_discovery/apps/api/serializers.py#L950 # https://github.com/inonit/drf-haystack/blob/master/drf_haystack/serializers.py#L373 field_data = self.instance.pop('fields', {}) query_data = self.format_query_facet_data(self.instance.pop('queries', {})) field_mapping = super(DistinctCountsAggregateFacetSearchSerializer, self).get_fields() field_mapping['fields'] = FacetDictField( child=FacetListField(child=DistinctCountsFacetFieldSerializer(field_data), required=False) ) field_mapping['queries'] = DictField( query_data, child=DistinctCountsQueryFacetFieldSerializer(), required=False ) if self.serialize_objects: field_mapping.move_to_end('objects') self.instance['fields'] = field_data self.instance['queries'] = query_data return field_mapping
Example #2
Source File: serializers.py From course-discovery with GNU Affero General Public License v3.0 | 5 votes |
def get_fields(self): query_facet_counts = self.instance.pop('queries', {}) field_mapping = super(BaseHaystackFacetSerializer, self).get_fields() query_data = self.format_query_facet_data(query_facet_counts) field_mapping['queries'] = DictField(query_data, child=QueryFacetFieldSerializer(), required=False) if self.serialize_objects: field_mapping.move_to_end('objects') self.instance['queries'] = query_data return field_mapping