Merge branch 'master' into version-3.0

This commit is contained in:
Tom Christie 2014-10-31 15:19:40 +00:00
commit 0e59c27e2f
2 changed files with 4 additions and 1 deletions

View File

@ -168,12 +168,13 @@ The `curl` command line tool may be useful for testing token authenticated APIs.
If you want every user to have an automatically generated Token, you can simply catch the User's `post_save` signal. If you want every user to have an automatically generated Token, you can simply catch the User's `post_save` signal.
from django.conf import settings
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.db.models.signals import post_save from django.db.models.signals import post_save
from django.dispatch import receiver from django.dispatch import receiver
from rest_framework.authtoken.models import Token from rest_framework.authtoken.models import Token
@receiver(post_save, sender=get_user_model()) @receiver(post_save, sender=settings.AUTH_USER_MODEL)
def create_auth_token(sender, instance=None, created=False, **kwargs): def create_auth_token(sender, instance=None, created=False, **kwargs):
if created: if created:
Token.objects.create(user=instance) Token.objects.create(user=instance)

View File

@ -9,6 +9,8 @@ envlist =
[testenv] [testenv]
commands = ./runtests.py --fast commands = ./runtests.py --fast
setenv =
PYTHONDONTWRITEBYTECODE=1
[testenv:flake8] [testenv:flake8]
basepython = python2.7 basepython = python2.7