diff --git a/docs/faq.rst b/docs/faq.rst index 4e4513d3..7973e77b 100644 --- a/docs/faq.rst +++ b/docs/faq.rst @@ -247,9 +247,27 @@ call is proxied through the entrypoint. Where should I put my extensions? / my extensions are not detected ------------------------------------------------------------------ -The extensions register themselves automatically. Just be sure that the python interpreter sees them at least once. -To that end, we suggest creating a ``PROJECT/schema.py`` file and importing it in your ``PROJECT/__init__.py`` -(same directory as ``settings.py`` and ``urls.py``) with ``import PROJECT.schema``. +The extensions register themselves automatically. Just be sure that the Python interpreter sees them at least once. +It is good practice to collect your extensions in ``YOUR_MAIN_APP_NAME/schema.py`` and to import that +file in your ``YOUR_MAIN_APP_NAME/apps.py``. Performing the import in the ``ready()`` method is the most robust +approach. It will make sure your environment (e.g. settings) is properly set up prior to loading. + + .. code-block:: python + + # your_main_app_name/apps.py + class YourMainAppNameConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "your_main_app_name" + + def ready(self): + import your_main_app_name.schema # noqa: E402 + + + +While there are certainly other ways of loading your extensions, this is a battle-proven and robust way to do it. +Generally in Django/DRF, importing stuff in the wrong order often results in weird errors or circular +import issues, which this approach tries to carefully circumvent. + My ``@action`` is erroneously paginated or has filter parameters that I do not want -----------------------------------------------------------------------------------