Skip to content

Commit

Permalink
Fix "RemovedInDjango40Warning: force_text()..." warning
Browse files Browse the repository at this point in the history
Currently, as of Django 3.0 (https://docs.djangoproject.com/en/3.0/releases/3.0/#features-deprecated-in-3-0), importing `force_text` causes a warning notice. This can clutter up test runs as warnings are surfaced by `pytest`, and other tools may have this issue as well.

The method has been renamed to `force_str`. However, note that `force_str` is not to be used with python 2.7, where you should instead continue to use `force_unicode`.

This PR fixes this issue while supporting all known configurations of python and django versions.
  • Loading branch information
eblume authored Aug 30, 2020
1 parent 260b9f3 commit cea49f4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion redis_sessions/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
try:
from django.utils.encoding import force_unicode
except ImportError: # Python 3.*
from django.utils.encoding import force_text as force_unicode
from django.utils.encoding import force_str as force_unicode
from django.contrib.sessions.backends.base import SessionBase, CreateError
from redis_sessions import settings

Expand Down

0 comments on commit cea49f4

Please sign in to comment.