Reputation: 25341
I'm developing a Django (3.1) app that only uses the Admin Site.
The default behavior is then to serve the Admin Site with the path:
http://localhost:8080/admin/
Which assumes that you have other sites at http://localhost:8080/other_site
Because my only site is the Admin Site, I'd like to serve the admin site at:
http://localhost:8080/
without the admin/
.
Here is the file website/urls.py
(website folder has all the settings/config)
from django.contrib import admin
from django.urls import include, path
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('management/', include('management.urls')),
path('admin/', admin.site.urls),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
And here is the file management/urls.py
(management is the app with all the models)
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
]
How can I do this?
I've tried updating website/urls.py
to include this
#path('management/', include('management.urls')),
path('/', admin.site.urls),
which I thought would disable the management
endpoint (it does) but it does not point the home path to the Admin Site.
Upvotes: 2
Views: 3083
Reputation: 793
If you want to change the url, just delete the admin/
from django.contrib import admin
from django.urls import include, path
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('management/', include('management.urls')),
path('', admin.site.urls), # here is a change
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Upvotes: 3