Advertisement
Guest User

Untitled

a guest
Aug 10th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. class Users(models.Model):
  2. group_id = models.IntegerField()
  3. name = models.CharField(max_length=100, null=True)
  4. email = models.CharField(max_length=100, null=True, unique=True)
  5. password = models.CharField(max_length=255, null=False)
  6. remember_token = models.CharField(max_length=255, null=True)
  7. activated = models.IntegerField(default=1)
  8. banned = models.IntegerField(default=0)
  9. ban_reason = models.CharField(max_length=255, null=True)
  10. otp = models.CharField(max_length=255, null=True)
  11. created_at = models.DateTimeField()
  12. updated_at = models.DateTimeField(null=True)
  13.  
  14. USERNAME_FIELD = 'email'
  15. REQUIRED_FIELDS = ['username','password',]
  16.  
  17. class Meta:
  18. managed = False
  19. db_table = 'users'
  20.  
  21. File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 149, in get_response
  22. response = self.process_exception_by_middleware(e, request)
  23. File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 147, in get_response
  24. response = wrapped_callback(request, *callback_args, **callback_kwargs)
  25. File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
  26. return view_func(*args, **kwargs)
  27. File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py", line 68, in view
  28. return self.dispatch(request, *args, **kwargs)
  29. File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py", line 466, in dispatch
  30. response = self.handle_exception(exc)
  31. File "/usr/local/lib/python2.7/dist-packages/rest_framework/views.py", line 463, in dispatch
  32. response = handler(request, *args, **kwargs)
  33. File "/usr/local/lib/python2.7/dist-packages/rest_framework_jwt/views.py", line 56, in post
  34. if serializer.is_valid():
  35. File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 213, in is_valid
  36. self._validated_data = self.run_validation(self.initial_data)
  37. File "/usr/local/lib/python2.7/dist-packages/rest_framework/serializers.py", line 410, in run_validation
  38. value = self.validate(value)
  39. File "/usr/local/lib/python2.7/dist-packages/rest_framework_jwt/serializers.py", line 50, in validate
  40. user = authenticate(**credentials)
  41. File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py", line 74, in authenticate
  42. user = backend.authenticate(**credentials)
  43. File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/backends.py", line 17, in authenticate
  44. user = UserModel._default_manager.get_by_natural_key(username)
  45. AttributeError: 'Manager' object has no attribute 'get_by_natural_key'
  46.  
  47. INSTALLED_APPS = [
  48. 'django.contrib.admin',
  49. 'django.contrib.auth',
  50. 'django.contrib.contenttypes',
  51. 'django.contrib.sessions',
  52. 'django.contrib.messages',
  53. 'django.contrib.staticfiles',
  54. 'testing',
  55. 'rest_framework',
  56. 'rest_framework_jwt',
  57. ]
  58.  
  59. REST_FRAMEWORK = {
  60. 'DEFAULT_PERMISSION_CLASSES': (
  61. 'rest_framework.permissions.IsAuthenticated',
  62. ),
  63. 'DEFAULT_AUTHENTICATION_CLASSES': (
  64. 'rest_framework.authentication.SessionAuthentication',
  65. 'rest_framework.authentication.BasicAuthentication',
  66. 'rest_framework_jwt.authentication.JSONWebTokenAuthentication',
  67. ),
  68. }
  69. AUTH_USER_MODEL = 'testing.Users'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement