aboutsummaryrefslogtreecommitdiffstats
path: root/api-guide/authentication.html
diff options
context:
space:
mode:
Diffstat (limited to 'api-guide/authentication.html')
-rw-r--r--api-guide/authentication.html6
1 files changed, 4 insertions, 2 deletions
diff --git a/api-guide/authentication.html b/api-guide/authentication.html
index 0b869df5..b0745359 100644
--- a/api-guide/authentication.html
+++ b/api-guide/authentication.html
@@ -335,10 +335,12 @@ print token.key
<hr />
<h4 id="generating-tokens">Generating Tokens</h4>
<p>If you want every user to have an automatically generated Token, you can simply catch the User's <code>post_save</code> signal.</p>
-<pre class="prettyprint lang-py"><code>from django.dispatch import receiver
+<pre class="prettyprint lang-py"><code>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)