Add swagger_fake_view marker to help detect fake views in get_serializer
Cleaner fix for #154
This commit is contained in:
@@ -174,6 +174,15 @@ in a few ways:
|
||||
:ref:`@swagger_auto_schema <custom-spec-swagger-auto-schema>`, to prevent ``get_serializer`` from being called on
|
||||
the view
|
||||
* :ref:`exclude your endpoint from introspection <custom-spec-excluding-endpoints>`
|
||||
* use the ``swagger_fake_view`` marker to detect requests generated by ``drf-yasg``:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def get_serializer_class(self):
|
||||
if getattr(self, 'swagger_fake_view', False):
|
||||
return TodoTreeSerializer
|
||||
|
||||
raise NotImplementedError("must not call this")
|
||||
|
||||
.. _SCRIPT_NAME: https://www.python.org/dev/peps/pep-0333/#environ-variables
|
||||
.. _FORCE_SCRIPT_NAME: https://docs.djangoproject.com/en/2.0/ref/settings/#force-script-name
|
||||
|
||||
Reference in New Issue
Block a user