0

Adding 'graphene_django' in INSTALLED_APPS = [ 'graphene_django' ] makes the django project makes the server to crush

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'graphene_django',
    "ingredients",
]

Here is the error that appears

 from django.utils.encoding import force_text
ImportError: cannot import name 'force_text' from 'django.utils.encoding' (/usr/local/lib/python3.9/site-packages/django/utils/encoding.py)
Byusa
  • 2,279
  • 1
  • 16
  • 21
  • 1
    Does this answer your question? [import error 'force\_text' from 'django.utils.encoding'](https://stackoverflow.com/questions/70382084/import-error-force-text-from-django-utils-encoding) – Iain Shelvington Jan 01 '22 at 23:09
  • No, it does not answer to my question at all. I have no where in the code that I am using 'force_text'. So changing ```force_text``` to ```force_str```, won't work for me (as that solution suggests) – Byusa Jan 01 '22 at 23:17
  • 1
    Just downgrade Django to version 3.X until all the packages you use have been updated for version 4 – Iain Shelvington Jan 01 '22 at 23:18
  • Yes, that worked(it removed the error), thank you. @IainShelvington – Byusa Jan 01 '22 at 23:49

1 Answers1

0

For django version 4.x

For Windows Go to project - YOUR_ENV/lib/site-packages/graphene_django/utils/utils.py

Find and replace - "force_text" to "force_str"
This worked for me.

Anurag A S
  • 725
  • 10
  • 23
Ganesh Teli
  • 1
  • 1
  • 1