Skip to content

Commit

Permalink
Fix for force_str vs force_text under python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
georgedorn committed Dec 23, 2019
1 parent 5860cdd commit 7d6dfbe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions tastypie/compat.py
Expand Up @@ -47,8 +47,10 @@ def unsalt_token(token):
return token


# compatability for force_text (deprecated) vs force_str (new)
try:
from django.utils.encoding import force_str # noqa
except ImportError:
# force_text deprecated in 2.2, removed in 3.0
# note that in 1.1.x, force_str and force_text both exist, but force_str behaves
# much differently on python 3 than python 2.
if django.VERSION < (2, 2):
from django.utils.encoding import force_text as force_str # noqa
else:
from django.utils.encoding import force_str # noqa

0 comments on commit 7d6dfbe

Please sign in to comment.