Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
501 views
in Technique[技术] by (71.8m points)

Django Utils six for Django 3.1.5

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Offical django page says:

Dont use it or switch to here (https://pypi.org/project/six/)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...