Correct the documentation of how to import extension snippets #1268
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The method currently documented here (adding to
PROJECT/schema.py
andPROJECT/__init__.py
) is too early, before the app is ready. Instead I copied the instructions at https://drf-spectacular.readthedocs.io/en/latest/customization.html#step-5-extensions which loads the extensions in the app'sready()
method.I literally copied the instructions text from customization step 5. You may want to remove this dupe and simply refer users to follow the step 5 instructions.
When using the approach of adding to
PROJECT/__init__.py
(orYOUR_MAIN_APP_NAME/__initi__.py
) drf-spectacular throws an error becauseDEFAULT_SCHEMA_CLASS
has not be properly initialized yet.Here's an example of where I do this: https://github.com/columbia-it/django-jsonapi-training/blob/spectacular/myapp/apps.py
I hope this makes sense and thanks for this project!