I've got a Django project with only one app.
I don't need the site admin (same as my app admin), so I would like to bypass the site admin and go directly to my app admin, i.e. go directly to mysite/admin/myapp/
after loging in and removing Home
in the breadcrumb.
How can I do that?
What you can do is override the admin index page to redirect to app specific admin page.
As stated by @FallenAngel, you need to update the urls.py to have your view for admin index page. That view can redirect to inner app admin page.
Django Url Dispatcher
scans all defined url definitions and redirect the request to the first matching url definition. At this point, url ordering is important, inurls.py
file of your project root:You can define an url redirection form the admin index page url to a custom view
So, if the request url is your admin index page, then your custom view will be called, if it is an admin page (that starts with
admin/
) but not admin index page, thenadmin.site.urls
will be executed...in your
myapp.views
write a simple redirection view:You can comment it out in the
INSTALLED_APPS
if you don't want that in your project. Just to remove it from admin you need to unregister. Check it out here.Another hack is, you can override the admin url
mysite/admin/
to simply redirect tomysite/admin/myapp/
in which you don't need to define your own redirect view. Django DRY rocks there. :)For more customization you need to change the admin index page by customizing the admin templates. Doc is here. https://docs.djangoproject.com/en/1.3/intro/tutorial02/#customize-the-admin-index-page
The cleanest and easiest way is to use the generic
RedirectView
inurls.py
: