aboutsummaryrefslogtreecommitdiffstats
path: root/docs/api-guide/authentication.md
diff options
context:
space:
mode:
authorPhilip Douglas2013-07-31 07:45:05 -0700
committerPhilip Douglas2013-07-31 07:45:05 -0700
commitc058ab36b13a6979c57760d9af2eb21ec3165e7d (patch)
tree9c352f0ebaddf18b03e45de9bf4ee3ad53377e17 /docs/api-guide/authentication.md
parentbf8e71c455a47a53898f8239ac7dad47e5f1d53a (diff)
parent43a5f8183c90f1056bbf33bb1402e76883aeb1fd (diff)
downloaddjango-rest-framework-c058ab36b13a6979c57760d9af2eb21ec3165e7d.tar.bz2
Merge pull request #2 from tomchristie/master
Update to latest
Diffstat (limited to 'docs/api-guide/authentication.md')
-rwxr-xr-xdocs/api-guide/authentication.md14
1 files changed, 11 insertions, 3 deletions
diff --git a/docs/api-guide/authentication.md b/docs/api-guide/authentication.md
index 5d6e0d91..b1ab4622 100755
--- a/docs/api-guide/authentication.md
+++ b/docs/api-guide/authentication.md
@@ -121,7 +121,7 @@ To use the `TokenAuthentication` scheme, include `rest_framework.authtoken` in y
'rest_framework.authtoken'
)
-Make sure to run `manage.py syncdb` after changing your settings.
+Make sure to run `manage.py syncdb` after changing your settings. The `authtoken` database tables are managed by south (see [Schema migrations](#schema-migrations) below).
You'll also need to create tokens for your users.
@@ -184,9 +184,11 @@ The `obtain_auth_token` view will return a JSON response when valid `username` a
Note that the default `obtain_auth_token` view explicitly uses JSON requests and responses, rather than using default renderer and parser classes in your settings. If you need a customized version of the `obtain_auth_token` view, you can do so by overriding the `ObtainAuthToken` view class, and using that in your url conf instead.
-#### Custom user models
+#### Schema migrations
-The `rest_framework.authtoken` app includes a south migration that will create the authtoken table. If you're using a [custom user model][custom-user-model] you'll need to make sure that any initial migration that creates the user table runs before the authtoken table is created.
+The `rest_framework.authtoken` app includes a south migration that will create the authtoken table.
+
+If you're using a [custom user model][custom-user-model] you'll need to make sure that any initial migration that creates the user table runs before the authtoken table is created.
You can do so by inserting a `needed_by` attribute in your user migration:
@@ -201,6 +203,12 @@ You can do so by inserting a `needed_by` attribute in your user migration:
For more details, see the [south documentation on dependencies][south-dependencies].
+Also note that if you're using a `post_save` signal to create tokens, then the first time you create the database tables, you'll need to ensure any migrations are run prior to creating any superusers. For example:
+
+ python manage.py syncdb --noinput # Won't create a superuser just yet, due to `--noinput`.
+ python manage.py migrate
+ python manage.py createsuperuser
+
## SessionAuthentication
This authentication scheme uses Django's default session backend for authentication. Session authentication is appropriate for AJAX clients that are running in the same session context as your website.