0
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

Alotab
  • 19
  • 4
  • Check this answer https://stackoverflow.com/questions/70382084/import-error-force-text-from-django-utils-encoding0 – Mohamed ElKalioby Apr 09 '23 at 11:56
  • @MohamedElKalioby the error is gone but then comes with another error `cannot import name 'ugettext' from 'django.utils.translation'`. – Alotab Apr 09 '23 at 12:06
  • This has been removed as well, search google to get the equivalent answer from stackoverflow – Mohamed ElKalioby Apr 09 '23 at 12:07
  • Please include *code*, not *images of code*: see [*Why not upload images of code errors when asking a question*](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question). [edit] the question and include code fragments. – Willem Van Onsem Apr 09 '23 at 12:15
  • @WillemVanOnsem sorry about that but the problem has nothing to do with my code cos I have little code. that's a user model code. This problem was about two different packages not working together. it's working now because I had to downgrade to django==3.*. – Alotab Apr 09 '23 at 12:28

1 Answers1

0

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.

Ahtisham
  • 9,170
  • 4
  • 43
  • 57