title: how to change a default django admin login view to generate token on login to admin site
body: <p>my site.py:</p>
  
  <pre><code>from django.contrib.admin import AdminSite
  
  
  class OptiAdminSite(AdminSite):
      def get_urls(self):
          from django.conf.urls import patterns, url, include
          from core import views
      from django.contrib.contenttypes import views as contenttype_views
  
      urlpatterns = patterns('',
          #url(r'^$', wrap(self.index), name='index'),
          url(r'^login/$', views.login, name='login'),
          url(r'^logout/$', views.logout, name='logout'),
        )
      return urlpatterns
  
  opti_site = OptiAdminSite()
  </code></pre>
  
  <p>I'm developing an authentication API. When user logs in to my API it generates a code which get destroyed once user hit logout.</p>
  
  <p>My problem is that whenever I'm running my API and django admin site in same browser, then if I login into admin-site It automatically login me in my API too with out any token. When I try to logout in that case from my API it generates an error - <code>'Token does not exist'</code>. I want to generate token when admin user login to admin-site.</p>
  
  <p>I've tried to do it with above trick as in official documentation but didn't find the right way to do it.</p>
  
  <p>Please suggest me the correct way to do it. Is it necessary to make a separate app for it?</p>
  
  <p>Thanks! in advance.</p>