DEV Community

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

Collapse
 
irfanharunk profile image
irfan harun

Hi there,

I just downloaded the code from github and i keep getting the following error :
cannot import name 'six' from 'django.utils'.

Please help me resolve the issue. Thanks

Collapse
 
thedevtimeline profile image
Rashid

Hey! That's removed in Django 3.0. django-cors-headers supports Django up until 2.1 right now. So, try to use six library instead of

django.utils.six
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 :)