Search code examples
pythondjangodjango-rest-frameworkstatic-methodsclass-method

Why do Django REST Framework Renderer and Parsers have to be instantiated and do not offer their key methods as static/class methods?


Like Djangos rest_framework.JSONRenderer it needs to be instantiated like

json = JSONRenderer().render(serializer.data)

in order to use the render method.

What's the background, that render() is not offered as a static/class method?


Solution

  • Using static/class methods makes it impossible to override/hard to debug to use object specific tools such as adding instance variables if someone requires it.