After enabling the administrator interface and starting the development web server on e.g. 128.0.0.1:8000, I am able to reach the admin interface on
128.0.0.1:8000/admin.
Obviously due the following URL namespace
url(r'^admin/', include(admin.site.urls)).
What do I have to do redirect requests on 128.0.0.1:8000/ automatically to 128.0.0.1:8000/admin?
The URL namespace
url(r'^$/', include(admin.site.urls))
does not seem to be the solution.
Click the URL Redirects tab. In the upper right, click Add URL redirect. In the right panel, select the Standard or Flexible redirect type. A standard redirect is used to redirect one URL to another.
Redirects allow you to forward the visitors of a specific URL to another page of your website. In Site Tools, you can add redirects by going to Domain > Redirects. Choose the desired domain, fill in the URL you want to redirect to another and add the URL of the new page destination. When ready, click Create.
in response to a POST request. Rather, the RFC simply states that the browser should alert the user and present an option to proceed or to cancel without reposting data to the new location. Unless you write complex server code, you can't force POST redirection and preserve posted data.
You can also use path instead of url which has been deprecated and is no longer available in Django 4.
from django.views.generic.base import RedirectView
urlpatterns = [
path('', RedirectView.as_view(url='/admin')),
path('admin/', admin.site.urls),
...
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With