A Custom User Model App for Everyone!

Denver Web Development & Web Software Applications | Rocky Meza Posted by rocky on May 29, 2013

When Django 1.5 was released, arguably the most exciting feature was the ability to have your own custom User model. All of the programmers here at Fusionbox were psyched for the cool things we were going to do with our custom User models.

Until we realized how much work it takes.

The 95% use case for having a custom User model is to use email as username. Implementing the required fields and methods for authentication and making it all work with the admin site almost doesn’t seem worth it for just that.

Also, we had disagreements over how to use the custom User model—whether to treat it as simply for authentication and authorization like Gavin argued in his blog post or if ditching the profile model for a much simpler and easier customized User model was the way to go.

Finally, when using a different User model in each of your projects, it could get cumbersome to get security updates out to each of them. If a new vulnerability is found and you have 100 trillion different implementations of auth, well, that’s a frightening scenario to say the least.

With all of these things combined, it makes something of a disincentive for using the exciting custom User model feature in our projects.

Introducing django-authtools

django-authtools is an app we wrote to make using the custom User model feature awesome. For the simple case, django-authtools provides the email as username User model that we’ve always wanted, but it’s much more than that.

Four short steps separate you from getting the email-as-username goodness.

  1. $ pip install django-authtools
  2. Add 'authtools' to your INSTALLED_APPS.
  3. Set AUTH_USER_MODEL = 'authtools.User' in your settings.py.
  4. Add url(r'^accounts/', include('authtools.urls')) to your URL conf.

That’s all you need to get an admin class, auth views, and an auth model in your project.

That being said, django-authtools is not just a custom User model. It provides abstract User models that implement the required auth and admin APIs so that you can make your own custom User without having to think about those.

One of the best features that django-authtools provides is the views. We wrote all of the auth views as classed-based views so that they gain all the modernity and extensibility of class-based views and they are User model agnostic, so they work with any User model. To ensure that they work correctly, we tested all of our views using Django’s own test cases.

Normally when you make your own User model, you would have to make your own Form classes that work with them. django-authtools has forms that work out of the box with any User model.

Where can I get it?

django-authtools is available for download on PyPI. The development for django-authtools happens on GitHub, pull requests are welcome. Get started with the documentation here.

For help with your Python development project, get in touch here.

Posted in: Denver Web Development, Programming

4 responses to "A Custom User Model App for Everyone!"

Denver Web Development & Web Software Applications | Rocky Meza

rocky (2/4/2014 @ 4:52pm)

Hey Ivan, Sungho. Thanks for you comments! We were tired of having to do it manually every time, so we made this so that nobody would ever have to do it again. Ivan, if you want to see more of our Django apps, you can see a bunch of them over on our GitHub Page. https://github.com/fusionbox

Sungho (1/4/2014 @ 8:12pm)

THANK YOU!!!!!!!!!!!!!! I spent so much time trying to make a full example from Django's Substituting a custom User model document with my own customization and my admin site (django auto gen) was keep throwing "no module named users". I googled for a long time and had no luck, but after this post thank god it is working. Thank you very much.

Robert (12/13/2013 @ 7:16am)

Awesome! How did you guys implement registration? The most supported registration apps (Django-userena and Django-registration) still don't have custom user support and it doesn't like like it's going to be supported soon either. Would be amazing if you'd make another blog post about that!

Ivan (11/26/2013 @ 7:09pm)

THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU I found this app after a looonggg battle with a very rough implementation of the same idea. Now how to solve the problem of all these app maintainers not supporting AUTH_USER_MODEL and/or email as username assumptions. Particularly the blog and forum app variety. If you have any other gems like this I would be very grateful.

Leave a Comment

Name: *

Email: *


Message: *

CONTACT US Got a comment? Want a quote?
Email or call 303.952.7490

Denver Web Design | Search Blog

Search Blog

Denver Web Design and Development | Blog Archives


Denver Interactive Agency | Blog Categories


Denver Website Design | Blog Tags


Ad Extensions AdWords agile agile marketing awards B2B Internet Marketing Binary Blogging Branding careers content development conversion optimization database denver advertising agency Denver computer programming Denver Interactive Agencies Denver Interactive Agency Denver Internet Marketing Denver Internet Marketing advice denver non profit marketing denver ppc denver ppc advertising denver programming denver programming jobs Denver search engine marketing Denver Search Engine Optimization Denver SEO denver seo agency Denver SEO intern denver social media Denver social media marketing Denver Software Development Denver Usability Denver usability consulting Denver web design Denver web designer Denver Web Development denver web sites Denver website design denver website development Django 1.5 facebook Favorite Restaurants Fusionbox Fusionbox food Fusionbox Framework google grants Google rankings HTML pages information architecture Internet Marketing JavaScript jobs keyword research KidsTek link building linkbuilding mobile web applications Non Profit Marketing online reputation management Pay per Click PDF pages PHP development post launch checklist PPC pre launch checklist Programming Project Management pubcon Python jobs reputation management Restaurant week 2013 Ruby jobs search engine optimization SEO SEO advice seo-friendly urls social media advice Social Media Marketing Social Media Marketing for Credit Unions social media sharing SQL stock photos TextMate Top B2B Interactive Agencies web design web designer in Denver Web Development web development jobs WORM