Skip to content

Commit 5c4bf53

Browse files
committed
Docs about migrations and post_save.
Documentation detailing requirement to migrate prior to running `createsuperuser` if using an authtoken `post_save` signal. Closes #987. Thanks to @yprez.
1 parent 82145e2 commit 5c4bf53

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

docs/api-guide/authentication.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,11 @@ The `obtain_auth_token` view will return a JSON response when valid `username` a
184184

185185
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.
186186

187-
#### Custom user models
187+
#### Schema migrations
188188

189-
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.
189+
The `rest_framework.authtoken` app includes a south migration that will create the authtoken table.
190+
191+
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.
190192

191193
You can do so by inserting a `needed_by` attribute in your user migration:
192194

@@ -201,6 +203,12 @@ You can do so by inserting a `needed_by` attribute in your user migration:
201203

202204
For more details, see the [south documentation on dependencies][south-dependencies].
203205

206+
Also not 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:
207+
208+
python manage.py syncdb --noinput # Won't create a superuser just yet, due to `--noinput`.
209+
python manage.py migrate
210+
python manage.py createsuperuser
211+
204212
## SessionAuthentication
205213

206214
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.

0 commit comments

Comments
 (0)