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
8eb4bb80
Commit
8eb4bb80
authored
Nov 17, 2012
by
Jonas Liljestrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved function for getting correct user model to compat.py
parent
cd482c0a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
rest_framework/authtoken/models.py
+2
-15
rest_framework/compat.py
+14
-0
No files found.
rest_framework/authtoken/models.py
View file @
8eb4bb80
import
uuid
import
hmac
from
hashlib
import
sha1
from
rest_framework.compat
import
User
from
django.db
import
models
from
django
import
VERSION
if
VERSION
[:
2
]
in
((
1
,
5
,),):
from
django.conf
import
settings
if
hasattr
(
settings
,
'AUTH_USER_MODEL'
):
user_model
=
settings
.
AUTH_USER_MODEL
else
:
from
django.contrib.auth.models
import
User
as
user_model
else
:
try
:
from
django.db.models.auth
import
User
as
user_model
except
ImportError
:
raise
ImportError
(
'User model is not to be found.'
)
class
Token
(
models
.
Model
):
"""
The default authorization token model.
"""
key
=
models
.
CharField
(
max_length
=
40
,
primary_key
=
True
)
user
=
models
.
OneToOneField
(
user_model
,
related_name
=
'auth_token'
)
user
=
models
.
OneToOneField
(
User
,
related_name
=
'auth_token'
)
created
=
models
.
DateTimeField
(
auto_now_add
=
True
)
def
save
(
self
,
*
args
,
**
kwargs
):
...
...
rest_framework/compat.py
View file @
8eb4bb80
...
...
@@ -27,6 +27,20 @@ def get_concrete_model(model_cls):
return
model_cls
# Django 1.5 add support for custom auth user model
if
django
.
VERSION
>=
(
1
,
5
):
from
django.conf
import
settings
if
hasattr
(
settings
,
'AUTH_USER_MODEL'
):
User
=
settings
.
AUTH_USER_MODEL
else
:
from
django.contrib.auth.models
import
User
else
:
try
:
from
django.db.models.auth
import
User
except
ImportError
:
raise
ImportError
(
'User model is not to be found.'
)
# First implementation of Django class-based views did not include head method
# in base View class - https://code.djangoproject.com/ticket/15668
if
django
.
VERSION
>=
(
1
,
4
):
...
...
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