Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Allowing an anonymous user to log in by only visiting a URL

Project Description

This is a simple application for Django that allows an anonymous visitor to log in as a user by only visiting a URL.

By default, the URL is only valid once and cannot be used multiple times. Other schemes that involve the number of visit and/or an expiry date can also be created. For example, it is possible to create a log in URL that only valid for 5 visits before next week using this application.


  1. Add django-loginurl application into your Django project. Modify your like the following:

  2. Add the authentication backend of this django-loginurl application to your project’s


    The first authentication backend is the default and if your project uses the Django’s standard authentication mechanism, you will need that.

    Consult the Django documentation for more information regarding the backend. See

  3. Include the application’s to your project.

    urlpatterns = patterns('',
        (r'^loginurl/', include('loginurl.urls')),

    This will make requests to loginurl/ are handled by django-loginurl. If the configuration is put inside the project’s, the log in URL will look like the following:

Scheduled Task

To keep your database clean from expired secret keys, a scheduled task need to be set up. This task should do one of the following.

  1. Call loginurl_cleanup command from the Django’s management script, or
  2. Open a special URL that will trigger the clean up, loginurl/cleanup/. e.g.

You can use crontab or the web based one to set this up. A daily or weekly task should be enough.


If your application need to create a one time log in URL, what you need to do is calling loginurl.utils.create with a user object as the parameter. The resulting object is an instance of loginurl.models.Key that has a property called key that contains a unique key for the log in URL.

import loginurl.utils

def create_login_url(user):
    key = loginurl.utils.create(user)
    url = '' % key.key

    return url


This code has been developed in the context of the research activities of the FET project (Grant agreement no. 231807).

Epiwork: developing the framework for an epidemic forecast infrastructure.


Release History

Release History

This version
History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django-loginurl-0.2.tar.gz (8.1 kB) Copy SHA256 Checksum SHA256 Source Jul 24, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting