I am a newbie in Django. Basically what I am looking for is - I want users to click on a link and login into the admin site. Can the parameters be passed in the URL itself ? Please help.
2 Answers
You can write your own view on your website that will:
- get the credentials from your URL
- authentificate the user using authenticate and login functions from django.contrib.auth (see https://docs.djangoproject.com/en/dev/topics/auth/default/#auth-web-requests)
- and then redirect your user to the admin URL using django redirect function (see https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#redirect)
1 Comment
Arovit
Clearly the way to go! Thank you okm / Patrice.
Register Your admin panel with django . https://docs.djangoproject.com/en/1.3/intro/tutorial02/#activate-the-admin-site
Change your urls.py like
from django.conf.urls.defaults import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Examples: # url(r'^$', 'mysite.views.home', name='home'), # url(r'^mysite/', include('mysite.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: url(r'^admin/', include(admin.site.urls)), ) Give the href as <a href = "www.yoursitename.com/admin/">Click</a>
You are done