Set email as username in Django 1.5

前端 未结 2 1027
孤独总比滥情好
孤独总比滥情好 2020-12-30 16:02

I am reading the docs at: https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#substituting-a-custom-user-model

So in my settings.py I put:



        
2条回答
  •  情歌与酒
    2020-12-30 16:39

    Unfortunately there's nothing within django.contrib.auth that you can simply subclass to get a model that has

    1. email address in place of user name and

    2. works nicely with other django.contrib.auth-stuff, like groups.

    The simplest approach is to copy models.py, admin.py and forms.py from django.contrib.auth, rip out user name all over the place and put in email address in it's place. I've done just that and I'm using it successfully in a couple of client projects.

    I've put it up on github and pypi so you can install it with

    pip install django-libtech-emailuser
    

    and check the usage instructions on github

提交回复
热议问题