Django admin using the flat theme, re-used to log in superusers from third-party application. Handy.

So far in my experience I used to have three kind of websites:

  1. Website with just a superuser
  2. Website with just a bunch of superusers
  3. Website with several users, both superusers and normal users (no access to the admin)

In the third case you have to setup some sort of registration/user-profile system. There are several choices, like django-registration, which however does not give you a full blown profile system like for example django-user-accounts.

In the first case you’ll be fine just using the admin login. You need to remember where is your admin login, especially if you use django-admin-honeypot, which I suggest.

So the complicated case is just number two. You want a way to login your other superuser, without passing by the admin login, but without going for a full blown registration application.

Rejoice! There is an easy way to do it. If your third party application is redirecting let’s say to /accounts/login, you can easily achieve that adding this two lines to your


urlpatterns = [

    .... # other urls
    url(r'^accounts/login/$', 'django.contrib.auth.views.login',
       {'template_name': 'admin/login.html'}),
    url(r'^accounts/logout/$', 'django.contrib.auth.views.logout'),

With these two line you will use the default django-template to handle the login and the logout of your only other superuser.

The page will look similar to the opening screenshot, if you are using the django-flat-theme, which is a very nice simple theme to add to the admin.