Turn your Django application in to an OpenID consumer
24th April 2007
I’ve just put the finishing touches on the first releasable version of django_openidconsumer, a package that makes it easy to add OpenID consumer support to any Django application.
Full documentation can be found in the repository. The package consists of Django models that implement the persistent part of an OpenID consumer, some simple views that hook in to the python-openid library from OpenID Enabled and a piece of middleware that makes the user’s OpenID(s) directly available within a Django view.
To cut a long story short, it allows you write view functions that look like this:
def example_view(request):
if request.openid:
return HttpResponse("OpenID is %s" % escape(
str(request.openid)
))
else:
return HttpResponse("No OpenID")
The package also supports simple registration, which lets you request additional details such as an e-mail address or nickname from the user’s OpenID provider.
I plan to keep the package under active development, with the aim of using it to demonstrate best practises in implementing OpenID (hence the support for multiple OpenIDs and simple registration out of the box). Next on the list is integration with Django’s built in authentication system, including the ability to associate one or more OpenIDs with an existing user account.
Please post any feedback as a comment on this entry, and direct bug reports to Google Code.
More recent articles
- Highlights from my appearance on the Data Renegades podcast with CL Kao and Dori Wilson - 26th November 2025
- Claude Opus 4.5, and why evaluating new LLMs is increasingly difficult - 24th November 2025
- sqlite-utils 4.0a1 has several (minor) backwards incompatible changes - 24th November 2025