Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct the documentation of how to import extension snippets #1268

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

n2ygk
Copy link
Contributor

@n2ygk n2ygk commented Jul 30, 2024

The method currently documented here (adding to PROJECT/schema.py and PROJECT/__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's ready() 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 (or YOUR_MAIN_APP_NAME/__initi__.py) drf-spectacular throws an error because DEFAULT_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!

The method documented here (adding to PROJECT/schema.py and PROJECT/__init__.py) is too early, before the app is ready. Instead copied the instructions at https://drf-spectacular.readthedocs.io/en/latest/customization.html#step-5-extensions which loads the extensions in the ready() method
@tfranzel
Copy link
Owner

excellent! I missed that one. thanks.

@tfranzel tfranzel merged commit f741899 into tfranzel:master Jul 30, 2024
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants