Remove python_2_unicode_compatible method
This commit is contained in:
@@ -24,22 +24,3 @@ def with_metaclass(meta, *bases):
|
||||
return meta(name, bases, d)
|
||||
|
||||
return type.__new__(metaclass, "temporary_class", (), {})
|
||||
|
||||
|
||||
def python_2_unicode_compatible(klass):
|
||||
"""
|
||||
A decorator that defines __unicode__ and __str__ methods under Python 2.
|
||||
Under Python 3 it does nothing.
|
||||
|
||||
To support Python 2 and 3 with a single code base, define a __str__ method
|
||||
returning text and apply this decorator to the class.
|
||||
"""
|
||||
if PY2:
|
||||
if "__str__" not in klass.__dict__:
|
||||
raise ValueError(
|
||||
"@python_2_unicode_compatible cannot be applied "
|
||||
"to %s because it doesn't define __str__()." % klass.__name__
|
||||
)
|
||||
klass.__unicode__ = klass.__str__
|
||||
klass.__str__ = lambda self: self.__unicode__().encode("utf-8")
|
||||
return klass
|
||||
|
||||
@@ -6,13 +6,11 @@ from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
|
||||
from polymorphic.compat import python_2_unicode_compatible
|
||||
from polymorphic.query import PolymorphicQuerySet
|
||||
|
||||
__all__ = ("PolymorphicManager", "PolymorphicQuerySet")
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class PolymorphicManager(models.Manager):
|
||||
"""
|
||||
Manager for PolymorphicModel
|
||||
|
||||
@@ -4,12 +4,10 @@ import re
|
||||
from django.db import models
|
||||
|
||||
from . import compat
|
||||
from .compat import python_2_unicode_compatible
|
||||
|
||||
RE_DEFERRED = re.compile("_Deferred_.*")
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class ShowFieldBase(object):
|
||||
""" base class for the ShowField... model mixins, does the work """
|
||||
|
||||
|
||||
Reference in New Issue
Block a user