I have a token generator that uses six
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.utils import six
class AccountActivationTokenGenerator(PasswordResetTokenGenerator):
def _make_hash_value(self, user, timestamp):
return (
six.text_type(user.pk) + six.text_type(timestamp) + six.text_type(user.is_active)
)
account_activation_token = AccountActivationTokenGenerator()
This runs on Django 2.2 but my boss told me to run this on latest 3.1.5. However, six was already depreciated.
I also checked this SO suggestion https://stackoverflow.com/a/65620383/13933721
Saying to do pip install django-six
then change from django.utils import six
to import six
I did the installation and changes to the code but it gives error message:
ModuleNotFoundError: No module named 'six'
I think I did something wrong or something is missing but I don't know how to proceed.
Here is my pip freeze for reference
asgiref==3.3.1
Django==3.1.5
django-six==1.0.4
djangorestframework==3.12.2
Pillow==8.1.0
pytz==2020.5
sqlparse==0.4.1
EDIT
It should had been pip install six
not pip install django-six
pip install six
fixed my issue
question from:
https://stackoverflow.com/questions/65950246/django-utils-six-for-django-3-1-5 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…