emailauth provides seamless email-based authentication for Django. It
leverages Django's own
contrib.auth package, extending where appropriate.
emailauth requires Django 1.5 or newer and Python 2.6/3.2 or newer.
How to install
$ pip install git+https://github.com/dfunckt/django-emailauth.git#egg=django-emailauth
$ git clone https://github.com/dfunckt/django-emailauth.git $ cd django-emailauth $ python setup.py install
How to use
Make sure you have
INSTALLED_APPS. (See the Django documentation for more details).
emailauth to your
INSTALLED_APPS = ( # ... 'django.contrib.contenttypes', 'django.contrib.auth', 'emailauth', # ... )
Order does not matter.
AUTH_USER_MODEL in your settings:
AUTH_USER_MODEL = 'emailauth.User'
It's important to note that you must set
creating any migrations or running
manage.py migrate for the first time.
migrate to create the database tables:
$ python manage.py migrate emailauth
You're done. Remember to always use get_user_model() when you need to reference the user model.
emailauth can be used either standalone as a direct replacement of
django.contrib.auth as described, or as a base to assist you with
boilerplate in order to implement your own email-based user model.
emailauth provides both an abstract and a concrete user model. If you want
to create your own email-based user model you should subclass
emailauth.models.AbstractUser. For example, to add a
phone field to
your user, you might do something like the following:
from django.db import models from emailauth.models import AbstractUser class User(AbstractUser): phone = models.CharField(max_length=15, blank=True)
Remember to change
AUTH_USER_MODEL to your user model in order to be
picked up by Django:
AUTH_USER_MODEL = 'myapp.User'