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

Only set SERVERS for drf-spectacular in production #3609

Merged
merged 2 commits into from Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 0 additions & 4 deletions {{cookiecutter.project_slug}}/config/settings/base.py
Expand Up @@ -346,10 +346,6 @@
"DESCRIPTION": "Documentation of API endpoints of {{ cookiecutter.project_name }}",
"VERSION": "1.0.0",
"SERVE_PERMISSIONS": ["rest_framework.permissions.IsAdminUser"],
"SERVERS": [
{"url": "http://127.0.0.1:8000", "description": "Local Development server"},
{"url": "https://{{ cookiecutter.domain_name }}", "description": "Production server"},
],
}
{%- endif %}
# Your stuff...
Expand Down
10 changes: 10 additions & 0 deletions {{cookiecutter.project_slug}}/config/settings/production.py
Expand Up @@ -358,5 +358,15 @@
traces_sample_rate=env.float("SENTRY_TRACES_SAMPLE_RATE", default=0.0),
)
{% endif %}
{% if cookiecutter.use_drf == "y" -%}

# django-rest-framework
# -------------------------------------------------------------------------------
# Tools that generate code samples can use SERVERS to point to the correct domain
SPECTACULAR_SETTINGS["SERVERS"] = [ # noqa F405
{"url": "https://{{ cookiecutter.domain_name }}", "description": "Production server"}
]

{%- endif %}
# Your stuff...
# ------------------------------------------------------------------------------