diff options
| author | Tom Christie | 2013-12-11 08:42:43 -0800 |
|---|---|---|
| committer | Tom Christie | 2013-12-11 08:42:43 -0800 |
| commit | 9c0da462094118171c976526cfde657f4d94daca (patch) | |
| tree | 0dade5e3b5aba8b342cd6ad1c634ec1d8f23262a /docs/api-guide | |
| parent | d3440f03118567495e331a51a76e8bce695a7128 (diff) | |
| parent | 4f473f0b9e918f2e071da0c84bd9b584c00ac919 (diff) | |
| download | django-rest-framework-9c0da462094118171c976526cfde657f4d94daca.tar.bz2 | |
Merge pull request #1283 from OddBloke/master
Add required imports to Generating Tokens example, and update with get_user_model()
Diffstat (limited to 'docs/api-guide')
| -rwxr-xr-x | docs/api-guide/authentication.md | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md index 1a1c68b8..53efc49a 100755 --- a/docs/api-guide/authentication.md +++ b/docs/api-guide/authentication.md @@ -162,10 +162,12 @@ 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. + from django.contrib.auth import get_user_model + from django.db.models.signals import post_save from django.dispatch import receiver from rest_framework.authtoken.models import Token - @receiver(post_save, sender=User) + @receiver(post_save, sender=get_user_model()) def create_auth_token(sender, instance=None, created=False, **kwargs): if created: Token.objects.create(user=instance) |
