Django version 4> just paste this snippet to your settinsg.py. Preferably on the top

    import django
    from django.utils.encoding import force_str
    django.utils.encoding.force_text = force_str

 same error and I solved it by installing Django with LTS. In this case pip install Django==3.2

just replace force_unicode with force_text if you use recent Django releases.

it worked for Django1.11 on both py2 and py3.

Problem occuring with Django-4. Till the PR gets merged, probably this monkeypatching might work (not tested in prod):

import django
from django.utils.encoding import force_str
django.utils.encoding.force_text = force_str

The "ImportError: cannot import name 'force_text' from 'django.utils.encoding'" occurs because the force_text method has been removed and replaced by force_str starting Django version 4.


upgrade the package that caused the issue and correct any import statements in your code.

From Django 4.0, the force_text() function is removed. Use the force_str() function instead of the force_text() function.


The force_str() function is part of the Django framework’s encoding module that decodes byte strings to text strings.

o use it, import it from the django.utils.encoding module like this:


from django.utils.encoding import force_str

from django.utils.encoding import force_str


def process_data(input):
  input_str = force_str(input)
  processed_input = input_str.upper()
  print(processed_input)


input = b'Gangsta Paradise'
processed_input = process_data(input)
pip install graphene-django --upgrade
import django
from django.utils.encoding import force_str
django.utils.encoding.force_text = force_str