def get_json_data(self, context):
'''
Default implementation: remove some auto-injected but not
JSON-serializable context variables.
If self.context_json_filter is set to a collection such as list or
set, then it instead preserves only the key-value pairs whose key is
in the filter.
You may override this method to implement your own serialization and
context filtering process.
'''
if self.context_json_filter is None:
if isinstance(self, SingleObjectMixin):
name = self.get_context_object_name(self.object)
if name in context: del context[name]
if 'object' in context: del context['object']
if isinstance(self, ContextMixin):
if 'view' in context: del context['view']
return context
else:
return {k: v for k, v in context.items()
if k in self.context_json_filter}