From fc081ce1fef82d71e1f8e948821623354884b147 Mon Sep 17 00:00:00 2001 From: ghazi-git Date: Tue, 6 Dec 2022 14:26:24 -0500 Subject: [PATCH] set SERVERS in production settings instead of base settings (#3609) fixes https://github.com/cookiecutter/cookiecutter-django/issues/3593 --- {{cookiecutter.project_slug}}/config/settings/base.py | 4 ---- .../config/settings/production.py | 10 ++++++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/{{cookiecutter.project_slug}}/config/settings/base.py b/{{cookiecutter.project_slug}}/config/settings/base.py index 52798146..1989fd8c 100644 --- a/{{cookiecutter.project_slug}}/config/settings/base.py +++ b/{{cookiecutter.project_slug}}/config/settings/base.py @@ -350,10 +350,6 @@ SPECTACULAR_SETTINGS = { "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... diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index 15d3a768..5de0529e 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -368,5 +368,15 @@ sentry_sdk.init( 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... # ------------------------------------------------------------------------------