A Custom User Model App for Everyone!
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.
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.
$ pip install django-authtools
AUTH_USER_MODEL = 'authtools.User'in your settings.py.
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?
For help with your Python development project, get in touch here.
4 responses to "A Custom User Model App for Everyone!"
Got a comment? Want a quote?
Email or call 303.952.7490
Credit Union Marketing (1)
Database Administration (3)
Denver Advertising (10)
Denver Internet Marketing (44)
Denver SEO (69)
Denver Web Design (30)
Denver Web Development (34)
Information Architecture (5)
Integrated Interactive (9)
Lead Generation (9)
Non-Profit Marketing (7)
SEO Advice (58)
Social Media Marketing (26)
Web Design (12)