0

I've deployed my Django (DRF API) project on DigitalOcean apps. The path "/" is used by my static site that uses this API so I set route for this component to "/api" which works correctly.

The problem:

I go to /api/admin/ and it redirects me to /admin/login but the django is served on /api url so this URL is invalid.

Do you know how to make this work?

Is there a way to tell django to use absolute URL everywhere?

Milano
  • 18,048
  • 37
  • 153
  • 353
  • There's some relevant information [in this post](https://stackoverflow.com/questions/44987110/django-in-subdirectory-admin-site-is-not-working). But it's highly dependant on stack used. –  Apr 02 '21 at 02:18

1 Answers1

0

urls.py

urlpatterns = [
    ...
    path("api/admin/", admin.site.urls),
    ...
]
Chris
  • 341
  • 3
  • 9
  • 1
    Thanks but no, the problem is more difficult. The `/api/` is in fact just `/` from Django project perspective. It's just served on `/api/` url but the project doesn't know about that. – Milano Apr 02 '21 at 01:32
  • The "/" and admin urls are hard coded in django.contrib.admin. Why don't you put it on a subdomain api.project.com? Unless you want to change Django/contrib/admin/sites.py :) – Chris Apr 02 '21 at 01:47
  • That's the way I will go, I was just curious if this is somehow possible. – Milano Apr 02 '21 at 01:50