I'm writing the backend for my app using django and django-rest-framework.
The problem I have is that when I set DEBUG=False
in my settings, the admin site (along with the browseable rest API) is no longer available, and I got a 500 response.
The console shows no error. Here is a capture of the console log when I try to access /admin/.
The rest API when queried/posted using JSON still works normally.
This is my urlspatterns (I also tried including /admin at the top of the list)
urlpatterns = [
path("", index, name="index"),
path("api/", include(router.urls)),
path("admin/", admin.site.urls),
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
]
Since I'm creating my app using react, I'm testing a project structured in a way that all the django apps are contained in the same folder, being the main app: backend. I had to make some minor changes in the apps to accommodate this structure.
For instance, this is an excerpt of how the installed apps:
INSTALLED_APPS = [
...
"rest_framework",
"backend",
"backend.projects",
"backend.tasks",
"backend.subtasks",
"backend.comments",
]
And this is a capture of the folder tree.
I think it must be something that changes in app/template discovery when changing from DEBUG=True to False.
Point out that everything else apart from that works correctly: the root of my backend is serving the react app correctly, rest API works correctly as well. And with DEBUG=True all works like a charm.