DEV Community

Discussion on: Create Advanced User Sign Up View in Django | Step-by-Step

Collapse
 
sree profile image
Sreejith Muralidharan

If you are using Django3,

pip install six

add six to the settings.py INSTALLED_APPS and migrate.

from django.contrib.auth.tokens import PasswordResetTokenGenerator
from six import text_type

class AccountActivationTokenGenerator(PasswordResetTokenGenerator):
    def _make_hash_value(self, user, timestamp):
        return (
            text_type(user.pk) + text_type(timestamp) +
            text_type(user.profile.signup_confirmation)
        )

account_activation_token = AccountActivationTokenGenerator()
Enter fullscreen mode Exit fullscreen mode
Collapse
 
jhoanmartinez profile image
Jhoan Martinez Silva

Worked great, adding to setting.py, huge thanks

Collapse
 
khoding profile image
Julien

hey this doesn't work for me... you say add six to settings.py, do you mean like this ?

INSTALLED_APPS = [
    ...
    'django.contrib.staticfiles',
    'six',
]
Enter fullscreen mode Exit fullscreen mode

Because I always get "Name 'six' is not defined"
And then what do I have to migrate ?

Thread Thread
 
sree profile image
Sreejith Muralidharan

That’s right. Can you try pip freeze and check, six was installed correctly?

Thread Thread
 
khoding profile image
Julien

I managed to fix it after a few tries, so it's good now :)