Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
715bd47d
Commit
715bd47d
authored
Jun 26, 2013
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use AUTH_USER_MODEL consistently between various Django versions. Closes #946
parent
13a3c993
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
10 deletions
+6
-10
rest_framework/authtoken/models.py
+2
-2
rest_framework/compat.py
+2
-8
rest_framework/runtests/settings.py
+2
-0
No files found.
rest_framework/authtoken/models.py
View file @
715bd47d
import
uuid
import
uuid
import
hmac
import
hmac
from
hashlib
import
sha1
from
hashlib
import
sha1
from
rest_framework.compat
import
User
from
rest_framework.compat
import
AUTH_USER_MODEL
from
django.conf
import
settings
from
django.conf
import
settings
from
django.db
import
models
from
django.db
import
models
...
@@ -11,7 +11,7 @@ class Token(models.Model):
...
@@ -11,7 +11,7 @@ class Token(models.Model):
The default authorization token model.
The default authorization token model.
"""
"""
key
=
models
.
CharField
(
max_length
=
40
,
primary_key
=
True
)
key
=
models
.
CharField
(
max_length
=
40
,
primary_key
=
True
)
user
=
models
.
OneToOneField
(
User
,
related_name
=
'auth_token'
)
user
=
models
.
OneToOneField
(
AUTH_USER_MODEL
,
related_name
=
'auth_token'
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
class
Meta
:
class
Meta
:
...
...
rest_framework/compat.py
View file @
715bd47d
...
@@ -83,15 +83,9 @@ def get_concrete_model(model_cls):
...
@@ -83,15 +83,9 @@ def get_concrete_model(model_cls):
# Django 1.5 add support for custom auth user model
# Django 1.5 add support for custom auth user model
if
django
.
VERSION
>=
(
1
,
5
):
if
django
.
VERSION
>=
(
1
,
5
):
from
django.conf
import
settings
from
django.conf
import
settings
if
hasattr
(
settings
,
'AUTH_USER_MODEL'
):
AUTH_USER_MODEL
=
settings
.
AUTH_USER_MODEL
User
=
settings
.
AUTH_USER_MODEL
else
:
from
django.contrib.auth.models
import
User
else
:
else
:
try
:
AUTH_USER_MODEL
=
'auth.User'
from
django.contrib.auth.models
import
User
except
ImportError
:
raise
ImportError
(
"User model is not to be found."
)
if
django
.
VERSION
>=
(
1
,
5
):
if
django
.
VERSION
>=
(
1
,
5
):
...
...
rest_framework/runtests/settings.py
View file @
715bd47d
...
@@ -134,6 +134,8 @@ PASSWORD_HASHERS = (
...
@@ -134,6 +134,8 @@ PASSWORD_HASHERS = (
'django.contrib.auth.hashers.CryptPasswordHasher'
,
'django.contrib.auth.hashers.CryptPasswordHasher'
,
)
)
AUTH_USER_MODEL
=
'auth.User'
import
django
import
django
if
django
.
VERSION
<
(
1
,
3
):
if
django
.
VERSION
<
(
1
,
3
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment