ImportError: cannot import name 'force_text' from 'django.utils.encoding'

793 Views Asked by At
from django.db import models 
from django.contrib.auth.models import AbstractUser

class ExtendUser(AbstractUser):
email = models.EmailField(blank=False, unique=True)
EMAIL_FIELD = 'email
USERNAME_FIELD = 'username

settings.py

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'graphene_django',
'graphql_auth',
"graphql_jwt.refresh_token.apps.RefreshTokenConfig",

'user',

]

I'm working on a Django GraphQL-JWT project and everything seems working until I pip install django-graphql-auth and then add graphene_django in my INSTALLED APPS that's when I get this error when I try python manage.py migrate or runserver.

enter image description here

1

There are 1 best solutions below

0
Ahtisham On

Dowgrading to older version of Django is not a good solution. The packages you are using are not supporting Django 4 hence the issues. You should do one of the following:

  • Check other alternative packages that do support Django 4. I believe you can use Simple JWT which does support Django 4.

  • If you don't want to use other package you can just update the existing package codebase by replacing ugettext to gettext and force_text to force_str as these have been updated in newer version of django.