Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
removed AUTH_USER_MODEL compat property
  • Loading branch information
auvipy committed Jun 7, 2016
commit 7dca49cb1814bcbcae9c51e0f15ac35f0d1c242f
14 changes: 5 additions & 9 deletions rest_framework/authtoken/models.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import binascii
import os

from django.conf import settings
from django.conf import AUTH_USER_MODEL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need settings to test whether or not the authtoken is in the INSTALLED_APPS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you elaborate why importing AUTH_USER_MODEL directly ?
Django documentation imports settings and use settings.AUTH_USER_MODEL.

from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _

# Prior to Django 1.5, the AUTH_USER_MODEL setting does not exist.
# Note that we don't perform this code in the compat module due to
# bug report #1297
# See: https://github.com/tomchristie/django-rest-framework/issues/1297
AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')


@python_2_unicode_compatible
class Token(models.Model):
"""
The default authorization token model.
"""
key = models.CharField(_("Key"), max_length=40, primary_key=True)
user = models.OneToOneField(AUTH_USER_MODEL, related_name='auth_token',
on_delete=models.CASCADE, verbose_name=_("User"))
user = models.OneToOneField(
AUTH_USER_MODEL, related_name='auth_token',
on_delete=models.CASCADE, verbose_name=_("User")
)
created = models.DateTimeField(_("Created"), auto_now_add=True)

class Meta:
Expand Down