tomchristie/django-rest-framework — pull request #2064 by fdemmer (2014-11-11 13:28:49+00:00)
Title: add kwargs to get_serializer_context

to add something to the context you can easily overload the get_serializer_context method. inside you have to call super to get the context, add your stuff and return it. it would save a little boilerplate if we would a take kwargs on the original method. that way the overloaded method is reduced to just the super call with the additional parameters for the context.

instead of:

def get_serializer_context(self):
context = super(SuperClass, self).get_serializer_context()
context.update(dict(
example=True
))
return context

just do:

def get_serializer_context(self):
return super(SuperClass, self).get_serializer_context(
example=True
)