Skip to content

Commit 45e675e

Browse files
authored
Add note about extensions registering themselves
1 parent 59f9749 commit 45e675e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

docs/customization.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ schema closer to your API.
1111
Sane fallbacks are used wherever possible and some warnings might not even be relevant to you.
1212
The remaining issues can be solved with the following steps.
1313

14-
1514
Step 1: ``queryset`` and ``serializer_class``
1615
---------------------------------------------
1716
Introspection heavily relies on those two attributes. ``get_serializer_class()``
@@ -148,6 +147,13 @@ All extensions work on the same principle. You provide a ``target_class`` (impor
148147
string or actual class) and then state what `drf-spectcular` should use instead of what
149148
it would normally discover.
150149

150+
.. note:: The extensions register themselves automatically. Just be sure that the Python
151+
interpreter sees them at least once.
152+
To that end, we suggest creating a ``PROJECT/schema.py`` file and importing it in your
153+
``PROJECT/__init__.py`` (same directory as ``settings.py`` and ``urls.py``)
154+
with ``import PROJECT.schema``. Please do not import the file in
155+
``settings.py`` as this may potentially lead to cyclic import issues. Now you are all set.
156+
151157
.. note:: Only the first Extension matching the criteria is used. By setting the ``priority`` attribute
152158
on your extension, you can influence the matching order (default ``0``).
153159
Built-in Extensions have a priority of ``-1``. If you subclass built-in Extensions, don't forget to

0 commit comments

Comments
 (0)