From d6f2c2c79db9aa335c5ca0dcd6d6eba59d1968e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Czuba?= Date: Wed, 22 Jan 2025 07:12:40 +0100 Subject: [PATCH] Removed depricated django imports - support for django 5 --- .gitignore | 1 + rest_auth/registration/serializers.py | 2 +- rest_auth/registration/views.py | 2 +- rest_auth/serializers.py | 6 +++--- rest_auth/tests/mixins.py | 4 ++-- rest_auth/tests/test_api.py | 6 +++--- rest_auth/views.py | 2 +- setup.py | 4 ++-- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 894a44c..f30f258 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,7 @@ wheels/ .installed.cfg *.egg MANIFEST +.idea/ # PyInstaller # Usually these files are written by a python script from a template diff --git a/rest_auth/registration/serializers.py b/rest_auth/registration/serializers.py index 4f99c18..6baa1a4 100644 --- a/rest_auth/registration/serializers.py +++ b/rest_auth/registration/serializers.py @@ -1,5 +1,5 @@ from django.http import HttpRequest -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.auth import get_user_model try: diff --git a/rest_auth/registration/views.py b/rest_auth/registration/views.py index 0e0ab0d..bab1c1c 100644 --- a/rest_auth/registration/views.py +++ b/rest_auth/registration/views.py @@ -1,6 +1,6 @@ from django.conf import settings from django.utils.decorators import method_decorator -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.decorators.debug import sensitive_post_parameters from rest_framework.views import APIView diff --git a/rest_auth/serializers.py b/rest_auth/serializers.py index b645231..2000b2d 100644 --- a/rest_auth/serializers.py +++ b/rest_auth/serializers.py @@ -3,8 +3,8 @@ from django.conf import settings from django.contrib.auth.forms import PasswordResetForm, SetPasswordForm from django.contrib.auth.tokens import default_token_generator from django.utils.http import urlsafe_base64_decode as uid_decoder -from django.utils.translation import ugettext_lazy as _ -from django.utils.encoding import force_text +from django.utils.translation import gettext_lazy as _ +from django.utils.encoding import force_str from rest_framework import serializers, exceptions from rest_framework.exceptions import ValidationError @@ -205,7 +205,7 @@ class PasswordResetConfirmSerializer(serializers.Serializer): # Decode the uidb64 to uid to get User object try: - uid = force_text(uid_decoder(attrs['uid'])) + uid = force_str(uid_decoder(attrs['uid'])) self.user = UserModel._default_manager.get(pk=uid) except (TypeError, ValueError, OverflowError, UserModel.DoesNotExist): raise ValidationError({'uid': ['Invalid value']}) diff --git a/rest_auth/tests/mixins.py b/rest_auth/tests/mixins.py index 30b3d58..4ae25dd 100644 --- a/rest_auth/tests/mixins.py +++ b/rest_auth/tests/mixins.py @@ -2,7 +2,7 @@ import json from django.conf import settings from django.test.client import Client, MULTIPART_CONTENT -from django.utils.encoding import force_text +from django.utils.encoding import force_str from rest_framework import status from rest_framework import permissions @@ -59,7 +59,7 @@ class TestsMixin(object): self.response.json = {} if is_json and self.response.content: - self.response.json = json.loads(force_text(self.response.content)) + self.response.json = json.loads(force_str(self.response.content)) if status_code: self.assertEqual(self.response.status_code, status_code) diff --git a/rest_auth/tests/test_api.py b/rest_auth/tests/test_api.py index 9c5fd9e..46112ca 100644 --- a/rest_auth/tests/test_api.py +++ b/rest_auth/tests/test_api.py @@ -2,7 +2,7 @@ from django.test import TestCase, override_settings from django.contrib.auth import get_user_model from django.core import mail from django.conf import settings -from django.utils.encoding import force_text +from django.utils.encoding import force_str from allauth.account import app_settings as account_app_settings from rest_framework import status @@ -300,7 +300,7 @@ class APIBasicTests(TestsMixin, TestCase): data = { 'new_password1': self.NEW_PASS, 'new_password2': self.NEW_PASS, - 'uid': force_text(url_kwargs['uid']), + 'uid': force_str(url_kwargs['uid']), 'token': '-wrong-token-' } self.post(url, data=data, status_code=400) @@ -327,7 +327,7 @@ class APIBasicTests(TestsMixin, TestCase): data = { 'new_password1': self.NEW_PASS, 'new_password2': self.NEW_PASS, - 'uid': force_text(url_kwargs['uid']), + 'uid': force_str(url_kwargs['uid']), 'token': url_kwargs['token'] } url = reverse('rest_password_reset_confirm') diff --git a/rest_auth/views.py b/rest_auth/views.py index 0a0a982..d436fdd 100644 --- a/rest_auth/views.py +++ b/rest_auth/views.py @@ -6,7 +6,7 @@ from django.conf import settings from django.contrib.auth import get_user_model from django.core.exceptions import ObjectDoesNotExist from django.utils.decorators import method_decorator -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.decorators.debug import sensitive_post_parameters from rest_framework import status diff --git a/setup.py b/setup.py index 675b99d..324fe0b 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ f.close() setup( name='django-rest-auth', - version='0.9.5', + version='1.0.0', author='Sumit Chachra', author_email='chachra@tivix.com', url='http://github.com/Tivix/django-rest-auth', @@ -22,7 +22,7 @@ setup( keywords='django rest auth registration rest-framework django-registration api', zip_safe=False, install_requires=[ - 'Django>=1.8.0', + 'Django>=5.1', 'djangorestframework>=3.1.3', 'six>=1.9.0', ],