diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py index 724209dd0d..e3483a85b2 100644 --- a/django/contrib/admin/models.py +++ b/django/contrib/admin/models.py @@ -6,7 +6,7 @@ from django.contrib.contenttypes.models import ContentType from django.db import models from django.urls import NoReverseMatch, reverse from django.utils import timezone -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.text import get_text_list from django.utils.translation import ugettext, ugettext_lazy as _ @@ -31,7 +31,6 @@ class LogEntryManager(models.Manager): ) -@python_2_unicode_compatible class LogEntry(models.Model): action_time = models.DateTimeField( _('action time'), diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index edde9077ac..bb871513d7 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -38,7 +38,7 @@ from django.template.response import SimpleTemplateResponse, TemplateResponse from django.urls import reverse from django.utils import six from django.utils.decorators import method_decorator -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.html import format_html from django.utils.http import urlencode, urlquote from django.utils.safestring import mark_safe @@ -480,7 +480,6 @@ class BaseModelAdmin(six.with_metaclass(forms.MediaDefiningClass)): return request.user.has_module_perms(self.opts.app_label) -@python_2_unicode_compatible class ModelAdmin(BaseModelAdmin): "Encapsulates all admin options and functionality for a given model." diff --git a/django/contrib/auth/base_user.py b/django/contrib/auth/base_user.py index c6f4c9665c..4ec18bee17 100644 --- a/django/contrib/auth/base_user.py +++ b/django/contrib/auth/base_user.py @@ -10,7 +10,7 @@ from django.contrib.auth.hashers import ( ) from django.db import models from django.utils.crypto import get_random_string, salted_hmac -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ @@ -45,7 +45,6 @@ class BaseUserManager(models.Manager): return self.get(**{self.model.USERNAME_FIELD: username}) -@python_2_unicode_compatible class AbstractBaseUser(models.Model): password = models.CharField(_('password'), max_length=128) last_login = models.DateTimeField(_('last login'), blank=True, null=True) diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 2e9f3682d7..51b0d8fa63 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -7,7 +7,6 @@ from django.core.mail import send_mail from django.db import models from django.db.models.manager import EmptyManager from django.utils import six, timezone -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ from .validators import ASCIIUsernameValidator, UnicodeUsernameValidator @@ -35,7 +34,6 @@ class PermissionManager(models.Manager): ) -@python_2_unicode_compatible class Permission(models.Model): """ The permissions system provides a way to assign permissions to specific @@ -96,7 +94,6 @@ class GroupManager(models.Manager): return self.get(name=name) -@python_2_unicode_compatible class Group(models.Model): """ Groups are a generic way of categorizing users to apply permissions, or @@ -374,7 +371,6 @@ class User(AbstractUser): swappable = 'AUTH_USER_MODEL' -@python_2_unicode_compatible class AnonymousUser(object): id = None pk = None diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py index 83e38af441..d2812e5d2a 100644 --- a/django/contrib/contenttypes/fields.py +++ b/django/contrib/contenttypes/fields.py @@ -11,11 +11,10 @@ from django.db.models.fields.related import ( lazy_related_operation, ) from django.db.models.query_utils import PathInfo -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.functional import cached_property -@python_2_unicode_compatible class GenericForeignKey(object): """ Provide a generic many-to-one relation through the ``content_type`` and diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py index 6db6831fbc..9fe4a56767 100644 --- a/django/contrib/contenttypes/models.py +++ b/django/contrib/contenttypes/models.py @@ -2,7 +2,7 @@ from collections import defaultdict from django.apps import apps from django.db import models -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.translation import ugettext_lazy as _ @@ -133,7 +133,6 @@ class ContentTypeManager(models.Manager): self._cache.setdefault(using, {})[ct.id] = ct -@python_2_unicode_compatible class ContentType(models.Model): app_label = models.CharField(max_length=100) model = models.CharField(_('python model class name'), max_length=100) diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py index 02c93d657d..38cc9fd0fe 100644 --- a/django/contrib/flatpages/models.py +++ b/django/contrib/flatpages/models.py @@ -1,11 +1,10 @@ from django.contrib.sites.models import Site from django.db import models from django.urls import get_script_prefix -from django.utils.encoding import iri_to_uri, python_2_unicode_compatible +from django.utils.encoding import iri_to_uri from django.utils.translation import ugettext_lazy as _ -@python_2_unicode_compatible class FlatPage(models.Model): url = models.CharField(_('URL'), max_length=100, db_index=True) title = models.CharField(_('title'), max_length=200) diff --git a/django/contrib/gis/db/backends/base/models.py b/django/contrib/gis/db/backends/base/models.py index 8ae9f2b126..8c8bdc6346 100644 --- a/django/contrib/gis/db/backends/base/models.py +++ b/django/contrib/gis/db/backends/base/models.py @@ -1,9 +1,7 @@ from django.contrib.gis import gdal from django.utils import six -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class SpatialRefSysMixin(object): """ The SpatialRefSysMixin is a class used by the database-dependent diff --git a/django/contrib/gis/db/backends/oracle/models.py b/django/contrib/gis/db/backends/oracle/models.py index e1bf49050b..13fbbcba4f 100644 --- a/django/contrib/gis/db/backends/oracle/models.py +++ b/django/contrib/gis/db/backends/oracle/models.py @@ -9,10 +9,8 @@ """ from django.contrib.gis.db import models from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class OracleGeometryColumns(models.Model): "Maps to the Oracle USER_SDO_GEOM_METADATA table." table_name = models.CharField(max_length=32) diff --git a/django/contrib/gis/db/backends/postgis/models.py b/django/contrib/gis/db/backends/postgis/models.py index ddb3be1e5e..60090df99d 100644 --- a/django/contrib/gis/db/backends/postgis/models.py +++ b/django/contrib/gis/db/backends/postgis/models.py @@ -3,10 +3,8 @@ """ from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class PostGISGeometryColumns(models.Model): """ The 'geometry_columns' view from PostGIS. See the PostGIS diff --git a/django/contrib/gis/db/backends/spatialite/models.py b/django/contrib/gis/db/backends/spatialite/models.py index 7dca8896ee..82fed9fd19 100644 --- a/django/contrib/gis/db/backends/spatialite/models.py +++ b/django/contrib/gis/db/backends/spatialite/models.py @@ -3,10 +3,8 @@ """ from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class SpatialiteGeometryColumns(models.Model): """ The 'geometry_columns' table from SpatiaLite. diff --git a/django/contrib/gis/gdal/raster/source.py b/django/contrib/gis/gdal/raster/source.py index 4aea283dd8..f3a565ddc8 100644 --- a/django/contrib/gis/gdal/raster/source.py +++ b/django/contrib/gis/gdal/raster/source.py @@ -11,9 +11,7 @@ from django.contrib.gis.gdal.raster.const import GDAL_RESAMPLE_ALGORITHMS from django.contrib.gis.gdal.srs import SpatialReference, SRSException from django.contrib.gis.geometry.regex import json_regex from django.utils import six -from django.utils.encoding import ( - force_bytes, force_text, python_2_unicode_compatible, -) +from django.utils.encoding import force_bytes, force_text from django.utils.functional import cached_property @@ -52,7 +50,6 @@ class TransformPoint(list): self._raster.geotransform = gtf -@python_2_unicode_compatible class GDALRaster(GDALBase): """ Wraps a raster GDAL Data Source object. diff --git a/django/contrib/messages/storage/base.py b/django/contrib/messages/storage/base.py index 2273e97207..66cd41684b 100644 --- a/django/contrib/messages/storage/base.py +++ b/django/contrib/messages/storage/base.py @@ -1,11 +1,10 @@ from django.conf import settings from django.contrib.messages import constants, utils -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text LEVEL_TAGS = utils.get_level_tags() -@python_2_unicode_compatible class Message(object): """ Represents an actual message that can be stored in any of the supported diff --git a/django/contrib/redirects/models.py b/django/contrib/redirects/models.py index a52a89d642..7a876ec76b 100644 --- a/django/contrib/redirects/models.py +++ b/django/contrib/redirects/models.py @@ -1,10 +1,8 @@ from django.contrib.sites.models import Site from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ -@python_2_unicode_compatible class Redirect(models.Model): site = models.ForeignKey(Site, models.CASCADE, verbose_name=_('site')) old_path = models.CharField( diff --git a/django/contrib/sessions/base_session.py b/django/contrib/sessions/base_session.py index bd8e957aea..e9cdcfe1c6 100644 --- a/django/contrib/sessions/base_session.py +++ b/django/contrib/sessions/base_session.py @@ -3,7 +3,6 @@ This module allows importing AbstractBaseSession even when django.contrib.sessions is not in INSTALLED_APPS. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ @@ -24,7 +23,6 @@ class BaseSessionManager(models.Manager): return s -@python_2_unicode_compatible class AbstractBaseSession(models.Model): session_key = models.CharField(_('session key'), max_length=40, primary_key=True) session_data = models.TextField(_('session data')) diff --git a/django/contrib/sites/models.py b/django/contrib/sites/models.py index 9f849fa559..782453d35d 100644 --- a/django/contrib/sites/models.py +++ b/django/contrib/sites/models.py @@ -4,7 +4,6 @@ from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models from django.db.models.signals import pre_delete, pre_save from django.http.request import split_domain_port -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ SITE_CACHE = {} @@ -78,7 +77,6 @@ class SiteManager(models.Manager): return self.get(domain=domain) -@python_2_unicode_compatible class Site(models.Model): domain = models.CharField( diff --git a/django/contrib/sites/requests.py b/django/contrib/sites/requests.py index 81f2ba42d6..c5513d8358 100644 --- a/django/contrib/sites/requests.py +++ b/django/contrib/sites/requests.py @@ -1,7 +1,3 @@ -from django.utils.encoding import python_2_unicode_compatible - - -@python_2_unicode_compatible class RequestSite(object): """ A class that shares the primary interface of Site (i.e., it has diff --git a/django/core/checks/messages.py b/django/core/checks/messages.py index f1de41a63c..da198d72b9 100644 --- a/django/core/checks/messages.py +++ b/django/core/checks/messages.py @@ -1,4 +1,4 @@ -from django.utils.encoding import force_str, python_2_unicode_compatible +from django.utils.encoding import force_str # Levels DEBUG = 10 @@ -8,7 +8,6 @@ ERROR = 40 CRITICAL = 50 -@python_2_unicode_compatible class CheckMessage(object): def __init__(self, level, msg, hint=None, obj=None, id=None): diff --git a/django/core/files/base.py b/django/core/files/base.py index 7499629459..f797158881 100644 --- a/django/core/files/base.py +++ b/django/core/files/base.py @@ -3,12 +3,9 @@ from io import BytesIO, StringIO, UnsupportedOperation from django.core.files.utils import FileProxyMixin from django.utils import six -from django.utils.encoding import ( - force_bytes, force_str, force_text, python_2_unicode_compatible, -) +from django.utils.encoding import force_bytes, force_str, force_text -@python_2_unicode_compatible class File(FileProxyMixin): DEFAULT_CHUNK_SIZE = 64 * 2 ** 10 @@ -138,7 +135,6 @@ class File(FileProxyMixin): self.file.close() -@python_2_unicode_compatible class ContentFile(File): """ A File-like object that takes just raw content, rather than an actual file. diff --git a/django/core/files/uploadhandler.py b/django/core/files/uploadhandler.py index 748477c0fc..3741f372b2 100644 --- a/django/core/files/uploadhandler.py +++ b/django/core/files/uploadhandler.py @@ -8,7 +8,6 @@ from django.conf import settings from django.core.files.uploadedfile import ( InMemoryUploadedFile, TemporaryUploadedFile, ) -from django.utils.encoding import python_2_unicode_compatible from django.utils.module_loading import import_string __all__ = [ @@ -25,7 +24,6 @@ class UploadFileException(Exception): pass -@python_2_unicode_compatible class StopUpload(UploadFileException): """ This exception is raised when an upload must abort. diff --git a/django/db/migrations/exceptions.py b/django/db/migrations/exceptions.py index d3da26940f..7b2a6abc62 100644 --- a/django/db/migrations/exceptions.py +++ b/django/db/migrations/exceptions.py @@ -1,5 +1,4 @@ from django.db.utils import DatabaseError -from django.utils.encoding import python_2_unicode_compatible class AmbiguityError(Exception): @@ -44,7 +43,6 @@ class IrreversibleError(RuntimeError): pass -@python_2_unicode_compatible class NodeNotFoundError(LookupError): """ Raised when an attempt on a node is made that is not available in the graph. diff --git a/django/db/migrations/graph.py b/django/db/migrations/graph.py index 83422361c4..1729aa7b7a 100644 --- a/django/db/migrations/graph.py +++ b/django/db/migrations/graph.py @@ -6,7 +6,6 @@ from functools import total_ordering from django.db.migrations.state import ProjectState from django.utils import six from django.utils.datastructures import OrderedSet -from django.utils.encoding import python_2_unicode_compatible from .exceptions import CircularDependencyError, NodeNotFoundError @@ -18,7 +17,6 @@ RECURSION_DEPTH_WARNING = ( ) -@python_2_unicode_compatible @total_ordering class Node(object): """ @@ -102,7 +100,6 @@ class DummyNode(Node): raise NodeNotFoundError(self.error_message, self.key, origin=self.origin) -@python_2_unicode_compatible class MigrationGraph(object): """ Represents the digraph of all migrations in a project. diff --git a/django/db/migrations/migration.py b/django/db/migrations/migration.py index d8b993f725..d1a24d4361 100644 --- a/django/db/migrations/migration.py +++ b/django/db/migrations/migration.py @@ -1,10 +1,8 @@ from django.db.transaction import atomic -from django.utils.encoding import python_2_unicode_compatible from .exceptions import IrreversibleError -@python_2_unicode_compatible class Migration(object): """ The base class for all migrations. diff --git a/django/db/migrations/recorder.py b/django/db/migrations/recorder.py index 0dac81223d..7824228c97 100644 --- a/django/db/migrations/recorder.py +++ b/django/db/migrations/recorder.py @@ -1,7 +1,6 @@ from django.apps.registry import Apps from django.db import models from django.db.utils import DatabaseError -from django.utils.encoding import python_2_unicode_compatible from django.utils.timezone import now from .exceptions import MigrationSchemaMissing @@ -20,7 +19,6 @@ class MigrationRecorder(object): a row in the table always means a migration is applied. """ - @python_2_unicode_compatible class Migration(models.Model): app = models.CharField(max_length=255) name = models.CharField(max_length=255) diff --git a/django/db/models/base.py b/django/db/models/base.py index 2fbcf46a41..e18615d76d 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -27,9 +27,7 @@ from django.db.models.signals import ( ) from django.db.models.utils import make_model_tuple from django.utils import six -from django.utils.encoding import ( - force_str, force_text, python_2_unicode_compatible, -) +from django.utils.encoding import force_str, force_text from django.utils.functional import curry from django.utils.six.moves import zip from django.utils.text import capfirst, get_text_list @@ -37,7 +35,6 @@ from django.utils.translation import ugettext_lazy as _ from django.utils.version import get_version -@python_2_unicode_compatible class Deferred(object): def __repr__(self): return str('') diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index ddfcbb4f39..2e21a42672 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -25,9 +25,7 @@ from django.utils.dateparse import ( parse_date, parse_datetime, parse_duration, parse_time, ) from django.utils.duration import duration_string -from django.utils.encoding import ( - force_bytes, force_text, python_2_unicode_compatible, smart_text, -) +from django.utils.encoding import force_bytes, force_text, smart_text from django.utils.functional import Promise, cached_property, curry from django.utils.ipv6 import clean_ipv6_address from django.utils.itercompat import is_iterable @@ -91,7 +89,6 @@ def return_None(): @total_ordering -@python_2_unicode_compatible class Field(RegisterLookupMixin): """Base class for all field types""" diff --git a/django/db/models/manager.py b/django/db/models/manager.py index 5a8ad632d5..5b498d631b 100644 --- a/django/db/models/manager.py +++ b/django/db/models/manager.py @@ -5,10 +5,8 @@ from importlib import import_module from django.db import router from django.db.models.query import QuerySet from django.utils import six -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class BaseManager(object): # Tracks each time a Manager instance is created. Used to retain order. creation_counter = 0 diff --git a/django/db/models/options.py b/django/db/models/options.py index 943de0dd91..a4593d125a 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -16,7 +16,7 @@ from django.db.models.query_utils import PathInfo from django.utils import six from django.utils.datastructures import ImmutableList, OrderedSet from django.utils.deprecation import RemovedInDjango21Warning -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.functional import cached_property from django.utils.text import camel_case_to_spaces, format_lazy from django.utils.translation import override @@ -67,7 +67,6 @@ def make_immutable_fields_list(name, data): return ImmutableList(data, warning=IMMUTABLE_WARNING % name) -@python_2_unicode_compatible class Options(object): FORWARD_PROPERTIES = { 'fields', 'many_to_many', 'concrete_fields', 'local_concrete_fields', diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py index fa141b35ef..6faff6ffc9 100644 --- a/django/forms/boundfield.py +++ b/django/forms/boundfield.py @@ -5,7 +5,7 @@ from django.forms.utils import flatatt, pretty_name from django.forms.widgets import Textarea, TextInput from django.utils import six from django.utils.deprecation import RemovedInDjango21Warning -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.functional import cached_property from django.utils.html import conditional_escape, format_html, html_safe from django.utils.inspect import func_supports_parameter @@ -16,7 +16,6 @@ __all__ = ('BoundField',) @html_safe -@python_2_unicode_compatible class BoundField(object): "A Field plus data" def __init__(self, form, field, name): @@ -253,7 +252,6 @@ class BoundField(object): @html_safe -@python_2_unicode_compatible class BoundWidget(object): """ A container class used for iterating over widgets. This is useful for diff --git a/django/forms/forms.py b/django/forms/forms.py index 0f1fbef6c8..3971893aa2 100644 --- a/django/forms/forms.py +++ b/django/forms/forms.py @@ -13,7 +13,7 @@ from django.forms.fields import Field, FileField from django.forms.utils import ErrorDict, ErrorList, pretty_name # NOQA from django.forms.widgets import Media, MediaDefiningClass from django.utils import six -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.functional import cached_property from django.utils.html import conditional_escape, html_safe from django.utils.safestring import mark_safe @@ -59,7 +59,6 @@ class DeclarativeFieldsMetaclass(MediaDefiningClass): @html_safe -@python_2_unicode_compatible class BaseForm(object): # This is the main implementation of all the Form logic. Note that this # class is different than Form. See the comments by the Form class for more diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 1e5ec8ee6b..81788626e1 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -4,7 +4,6 @@ from django.forms.fields import BooleanField, IntegerField from django.forms.utils import ErrorList from django.forms.widgets import HiddenInput from django.utils import six -from django.utils.encoding import python_2_unicode_compatible from django.utils.functional import cached_property from django.utils.html import html_safe from django.utils.safestring import mark_safe @@ -46,7 +45,6 @@ class ManagementForm(Form): @html_safe -@python_2_unicode_compatible class BaseFormSet(object): """ A collection of instances of the same Form class. diff --git a/django/forms/utils.py b/django/forms/utils.py index 3e6991ea32..3a86f419df 100644 --- a/django/forms/utils.py +++ b/django/forms/utils.py @@ -4,7 +4,7 @@ import sys from django.conf import settings from django.core.exceptions import ValidationError # backwards compatibility from django.utils import six, timezone -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.html import escape, format_html, format_html_join, html_safe from django.utils.translation import ugettext_lazy as _ @@ -48,7 +48,6 @@ def flatatt(attrs): @html_safe -@python_2_unicode_compatible class ErrorDict(dict): """ A collection of errors that knows how to display itself in various formats. @@ -81,7 +80,6 @@ class ErrorDict(dict): @html_safe -@python_2_unicode_compatible class ErrorList(UserList, list): """ A collection of errors that knows how to display itself in various formats. diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 3ddad40ebb..c4bbb7fe4f 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -13,9 +13,7 @@ from django.forms.utils import to_current_timezone from django.templatetags.static import static from django.utils import datetime_safe, formats, six from django.utils.dates import MONTHS -from django.utils.encoding import ( - force_str, force_text, python_2_unicode_compatible, -) +from django.utils.encoding import force_str, force_text from django.utils.formats import get_format from django.utils.html import format_html, html_safe from django.utils.safestring import mark_safe @@ -38,7 +36,6 @@ MEDIA_TYPES = ('css', 'js') @html_safe -@python_2_unicode_compatible class Media(object): def __init__(self, media=None, **kwargs): if media: diff --git a/django/template/base.py b/django/template/base.py index 3aa7941879..aa30d2e2b3 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -57,9 +57,7 @@ from django.template.context import ( # NOQA: imported for backwards compatibil BaseContext, Context, ContextPopException, RequestContext, ) from django.utils import six -from django.utils.encoding import ( - force_str, force_text, python_2_unicode_compatible, -) +from django.utils.encoding import force_str, force_text from django.utils.formats import localize from django.utils.html import conditional_escape, escape from django.utils.inspect import getargspec @@ -115,7 +113,6 @@ class TemplateEncodingError(Exception): pass -@python_2_unicode_compatible class VariableDoesNotExist(Exception): def __init__(self, msg, params=()): diff --git a/django/test/html.py b/django/test/html.py index 94dc7f540e..fd78e6b713 100644 --- a/django/test/html.py +++ b/django/test/html.py @@ -5,7 +5,7 @@ Comparing two html documents. import re from django.utils import six -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.html_parser import HTMLParseError, HTMLParser WHITESPACE = re.compile(r'\s+') @@ -15,7 +15,6 @@ def normalize_whitespace(string): return WHITESPACE.sub(' ', string) -@python_2_unicode_compatible class Element(object): def __init__(self, name, attributes): self.name = name @@ -139,7 +138,6 @@ class Element(object): return six.text_type(self) -@python_2_unicode_compatible class RootElement(Element): def __init__(self): super(RootElement, self).__init__(None, ()) diff --git a/docs/internals/contributing/writing-code/coding-style.txt b/docs/internals/contributing/writing-code/coding-style.txt index fe0a21c5a5..abed891d63 100644 --- a/docs/internals/contributing/writing-code/coding-style.txt +++ b/docs/internals/contributing/writing-code/coding-style.txt @@ -228,10 +228,6 @@ Model style first_name = models.CharField(max_length=20) last_name = models.CharField(max_length=40) -* If you define a ``__str__`` method (previously ``__unicode__`` before Python 3 - was supported), decorate the model class with - :func:`~django.utils.encoding.python_2_unicode_compatible`. - * The order of model inner classes and standard methods should be as follows (noting that these are not all required): diff --git a/docs/intro/tutorial02.txt b/docs/intro/tutorial02.txt index bd7e9c18ca..f7bf850309 100644 --- a/docs/intro/tutorial02.txt +++ b/docs/intro/tutorial02.txt @@ -452,15 +452,12 @@ of this object. Let's fix that by editing the ``Question`` model (in the :filename: polls/models.py from django.db import models - from django.utils.encoding import python_2_unicode_compatible - @python_2_unicode_compatible # only if you need to support Python 2 class Question(models.Model): # ... def __str__(self): return self.question_text - @python_2_unicode_compatible # only if you need to support Python 2 class Choice(models.Model): # ... def __str__(self): diff --git a/docs/ref/models/instances.txt b/docs/ref/models/instances.txt index 83f76f37ca..838a4bd4de 100644 --- a/docs/ref/models/instances.txt +++ b/docs/ref/models/instances.txt @@ -601,9 +601,7 @@ representation of the model from the ``__str__()`` method. For example:: from django.db import models - from django.utils.encoding import python_2_unicode_compatible - @python_2_unicode_compatible # only if you need to support Python 2 class Person(models.Model): first_name = models.CharField(max_length=50) last_name = models.CharField(max_length=50) @@ -611,9 +609,6 @@ For example:: def __str__(self): return '%s %s' % (self.first_name, self.last_name) -If you'd like compatibility with Python 2, you can decorate your model class -with :func:`~django.utils.encoding.python_2_unicode_compatible` as shown above. - ``__eq__()`` ------------ diff --git a/docs/ref/unicode.txt b/docs/ref/unicode.txt index 3c29be550d..c167fd55b3 100644 --- a/docs/ref/unicode.txt +++ b/docs/ref/unicode.txt @@ -258,33 +258,6 @@ is *always* the case, even if the data could fit into an ASCII bytestring. You can pass in bytestrings when creating a model or populating a field, and Django will convert it to Unicode when it needs to. -Choosing between ``__str__()`` and ``__unicode__()`` ----------------------------------------------------- - -.. note:: - - If you are on Python 3, you can skip this section because you'll always - create ``__str__()`` rather than ``__unicode__()``. If you'd like - compatibility with Python 2, you can decorate your model class with - :func:`~django.utils.encoding.python_2_unicode_compatible`. - -One consequence of using Unicode by default is that you have to take some care -when printing data from the model. - -In particular, rather than giving your model a ``__str__()`` method, we -recommended you implement a ``__unicode__()`` method. In the ``__unicode__()`` -method, you can quite safely return the values of all your fields without -having to worry about whether they fit into a bytestring or not. (The way -Python works, the result of ``__str__()`` is *always* a bytestring, even if you -accidentally try to return a Unicode object). - -You can still create a ``__str__()`` method on your models if you want, of -course, but you shouldn't need to do this unless you have a good reason. -Django's ``Model`` base class automatically provides a ``__str__()`` -implementation that calls ``__unicode__()`` and encodes the result into UTF-8. -This means you'll normally only need to implement a ``__unicode__()`` method -and let Django handle the coercion to a bytestring when required. - Taking care in ``get_absolute_url()`` ------------------------------------- diff --git a/docs/topics/python3.txt b/docs/topics/python3.txt index 9dd4d83732..5b40f57bd3 100644 --- a/docs/topics/python3.txt +++ b/docs/topics/python3.txt @@ -148,27 +148,6 @@ In Python 3, there's simply :meth:`~object.__str__`, which must return ``str`` (It is also possible to define :meth:`~object.__bytes__`, but Django applications have little use for that method, because they hardly ever deal with ``bytes``.) -Django provides a simple way to define :meth:`~object.__str__` and -` __unicode__()`_ methods that work on Python 2 and 3: you must -define a :meth:`~object.__str__` method returning text and to apply the -:func:`~django.utils.encoding.python_2_unicode_compatible` decorator. - -On Python 3, the decorator is a no-op. On Python 2, it defines appropriate -` __unicode__()`_ and :meth:`~object.__str__` methods (replacing the -original :meth:`~object.__str__` method in the process). Here's an example:: - - from __future__ import unicode_literals - from django.utils.encoding import python_2_unicode_compatible - - @python_2_unicode_compatible - class MyClass(object): - def __str__(self): - return "Instance of my class" - -This technique is the best match for Django's porting philosophy. - -For forwards compatibility, this decorator is available as of Django 1.4.2. - Finally, note that :meth:`~object.__repr__` must return a ``str`` on all versions of Python. diff --git a/tests/admin_changelist/models.py b/tests/admin_changelist/models.py index fb5f03cbd6..0abb061548 100644 --- a/tests/admin_changelist/models.py +++ b/tests/admin_changelist/models.py @@ -1,5 +1,4 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible class Event(models.Model): @@ -27,7 +26,6 @@ class Band(models.Model): genres = models.ManyToManyField(Genre) -@python_2_unicode_compatible class Musician(models.Model): name = models.CharField(max_length=30) @@ -35,7 +33,6 @@ class Musician(models.Model): return self.name -@python_2_unicode_compatible class Group(models.Model): name = models.CharField(max_length=30) members = models.ManyToManyField(Musician, through='Membership') diff --git a/tests/admin_checks/models.py b/tests/admin_checks/models.py index 822d695e4d..3336ce878e 100644 --- a/tests/admin_checks/models.py +++ b/tests/admin_checks/models.py @@ -5,14 +5,12 @@ Tests of ModelAdmin system checks logic. from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible class Album(models.Model): title = models.CharField(max_length=150) -@python_2_unicode_compatible class Song(models.Model): title = models.CharField(max_length=150) album = models.ForeignKey(Album, models.CASCADE) diff --git a/tests/admin_custom_urls/models.py b/tests/admin_custom_urls/models.py index 5365ee34bd..840d9b9f38 100644 --- a/tests/admin_custom_urls/models.py +++ b/tests/admin_custom_urls/models.py @@ -4,10 +4,8 @@ from django.contrib import admin from django.db import models from django.http import HttpResponseRedirect from django.urls import reverse -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Action(models.Model): name = models.CharField(max_length=50, primary_key=True) description = models.CharField(max_length=70) diff --git a/tests/admin_filters/models.py b/tests/admin_filters/models.py index f508aa1f9b..d9ce5c7cfd 100644 --- a/tests/admin_filters/models.py +++ b/tests/admin_filters/models.py @@ -4,10 +4,8 @@ from django.contrib.contenttypes.fields import ( ) from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Book(models.Model): title = models.CharField(max_length=50) year = models.PositiveIntegerField(null=True, blank=True) @@ -39,7 +37,6 @@ class Book(models.Model): return self.title -@python_2_unicode_compatible class Department(models.Model): code = models.CharField(max_length=4, unique=True) description = models.CharField(max_length=50, blank=True, null=True) @@ -48,7 +45,6 @@ class Department(models.Model): return self.description -@python_2_unicode_compatible class Employee(models.Model): department = models.ForeignKey(Department, models.CASCADE, to_field="code") name = models.CharField(max_length=100) @@ -57,7 +53,6 @@ class Employee(models.Model): return self.name -@python_2_unicode_compatible class TaggedItem(models.Model): tag = models.SlugField() content_type = models.ForeignKey(ContentType, models.CASCADE, related_name='tagged_items') @@ -68,7 +63,6 @@ class TaggedItem(models.Model): return self.tag -@python_2_unicode_compatible class Bookmark(models.Model): url = models.URLField() tags = GenericRelation(TaggedItem) diff --git a/tests/admin_inlines/models.py b/tests/admin_inlines/models.py index e78511aaab..31e692b60e 100644 --- a/tests/admin_inlines/models.py +++ b/tests/admin_inlines/models.py @@ -6,10 +6,8 @@ import random from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Parent(models.Model): name = models.CharField(max_length=50) @@ -17,7 +15,6 @@ class Parent(models.Model): return self.name -@python_2_unicode_compatible class Teacher(models.Model): name = models.CharField(max_length=50) @@ -25,7 +22,6 @@ class Teacher(models.Model): return self.name -@python_2_unicode_compatible class Child(models.Model): name = models.CharField(max_length=50) teacher = models.ForeignKey(Teacher, models.CASCADE) diff --git a/tests/admin_utils/models.py b/tests/admin_utils/models.py index 87060cbff8..1af2f09411 100644 --- a/tests/admin_utils/models.py +++ b/tests/admin_utils/models.py @@ -1,10 +1,8 @@ from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ -@python_2_unicode_compatible class Site(models.Model): domain = models.CharField(max_length=100) @@ -34,7 +32,6 @@ class ArticleProxy(Article): proxy = True -@python_2_unicode_compatible class Count(models.Model): num = models.PositiveSmallIntegerField() parent = models.ForeignKey('self', models.CASCADE, null=True) diff --git a/tests/admin_views/models.py b/tests/admin_views/models.py index 54d8f5f968..89373f6ed3 100644 --- a/tests/admin_views/models.py +++ b/tests/admin_views/models.py @@ -11,10 +11,8 @@ from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ValidationError from django.core.files.storage import FileSystemStorage from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Section(models.Model): """ A simple section that links to articles, to test linking to related items @@ -33,7 +31,6 @@ class Section(models.Model): return self.name -@python_2_unicode_compatible class Article(models.Model): """ A simple article to test admin views. Test backwards compatibility. @@ -59,7 +56,6 @@ class Article(models.Model): model_year_reversed.short_description = '' -@python_2_unicode_compatible class Book(models.Model): """ A simple book that has chapters. @@ -70,7 +66,6 @@ class Book(models.Model): return self.name -@python_2_unicode_compatible class Promo(models.Model): name = models.CharField(max_length=100, verbose_name='¿Name?') book = models.ForeignKey(Book, models.CASCADE) @@ -79,7 +74,6 @@ class Promo(models.Model): return self.name -@python_2_unicode_compatible class Chapter(models.Model): title = models.CharField(max_length=100, verbose_name='¿Title?') content = models.TextField() @@ -93,7 +87,6 @@ class Chapter(models.Model): verbose_name = '¿Chapter?' -@python_2_unicode_compatible class ChapterXtra1(models.Model): chap = models.OneToOneField(Chapter, models.CASCADE, verbose_name='¿Chap?') xtra = models.CharField(max_length=100, verbose_name='¿Xtra?') @@ -102,7 +95,6 @@ class ChapterXtra1(models.Model): return '¿Xtra1: %s' % self.xtra -@python_2_unicode_compatible class ChapterXtra2(models.Model): chap = models.OneToOneField(Chapter, models.CASCADE, verbose_name='¿Chap?') xtra = models.CharField(max_length=100, verbose_name='¿Xtra?') @@ -120,7 +112,6 @@ class CustomArticle(models.Model): date = models.DateTimeField() -@python_2_unicode_compatible class ModelWithStringPrimaryKey(models.Model): string_pk = models.CharField(max_length=255, primary_key=True) @@ -131,7 +122,6 @@ class ModelWithStringPrimaryKey(models.Model): return '/dummy/%s/' % self.string_pk -@python_2_unicode_compatible class Color(models.Model): value = models.CharField(max_length=10) warm = models.BooleanField(default=False) @@ -146,7 +136,6 @@ class Color2(Color): proxy = True -@python_2_unicode_compatible class Thing(models.Model): title = models.CharField(max_length=20) color = models.ForeignKey(Color, models.CASCADE, limit_choices_to={'warm': True}) @@ -156,7 +145,6 @@ class Thing(models.Model): return self.title -@python_2_unicode_compatible class Actor(models.Model): name = models.CharField(max_length=50) age = models.IntegerField() @@ -166,7 +154,6 @@ class Actor(models.Model): return self.name -@python_2_unicode_compatible class Inquisition(models.Model): expected = models.BooleanField(default=False) leader = models.ForeignKey(Actor, models.CASCADE) @@ -176,7 +163,6 @@ class Inquisition(models.Model): return "by %s from %s" % (self.leader, self.country) -@python_2_unicode_compatible class Sketch(models.Model): title = models.CharField(max_length=100) inquisition = models.ForeignKey( @@ -213,7 +199,6 @@ def today_callable_q(): return models.Q(last_action__gte=datetime.datetime.today()) -@python_2_unicode_compatible class Character(models.Model): username = models.CharField(max_length=100) last_action = models.DateTimeField() @@ -222,7 +207,6 @@ class Character(models.Model): return self.username -@python_2_unicode_compatible class StumpJoke(models.Model): variation = models.CharField(max_length=100) most_recently_fooled = models.ForeignKey( @@ -248,7 +232,6 @@ class Fabric(models.Model): surface = models.CharField(max_length=20, choices=NG_CHOICES) -@python_2_unicode_compatible class Person(models.Model): GENDER_CHOICES = ( (1, "Male"), @@ -263,7 +246,6 @@ class Person(models.Model): return self.name -@python_2_unicode_compatible class Persona(models.Model): """ A simple persona associated with accounts, to test inlining of related @@ -275,7 +257,6 @@ class Persona(models.Model): return self.name -@python_2_unicode_compatible class Account(models.Model): """ A simple, generic account encapsulating the information shared by all @@ -299,7 +280,6 @@ class BarAccount(Account): servicename = 'bar' -@python_2_unicode_compatible class Subscriber(models.Model): name = models.CharField(blank=False, max_length=80) email = models.EmailField(blank=False, max_length=175) @@ -349,7 +329,6 @@ class Child(models.Model): raise ValidationError('invalid') -@python_2_unicode_compatible class EmptyModel(models.Model): def __str__(self): return "Primary key = %s" % self.id @@ -433,7 +412,6 @@ class FancyDoodad(Doodad): expensive = models.BooleanField(default=True) -@python_2_unicode_compatible class Category(models.Model): collector = models.ForeignKey(Collector, models.CASCADE) order = models.PositiveIntegerField() @@ -489,7 +467,6 @@ class FieldOverridePost(Post): proxy = True -@python_2_unicode_compatible class Gadget(models.Model): name = models.CharField(max_length=100) @@ -497,7 +474,6 @@ class Gadget(models.Model): return self.name -@python_2_unicode_compatible class Villain(models.Model): name = models.CharField(max_length=100) @@ -509,7 +485,6 @@ class SuperVillain(Villain): pass -@python_2_unicode_compatible class FunkyTag(models.Model): "Because we all know there's only one real use case for GFKs." name = models.CharField(max_length=25) @@ -521,7 +496,6 @@ class FunkyTag(models.Model): return self.name -@python_2_unicode_compatible class Plot(models.Model): name = models.CharField(max_length=100) team_leader = models.ForeignKey(Villain, models.CASCADE, related_name='lead_plots') @@ -532,7 +506,6 @@ class Plot(models.Model): return self.name -@python_2_unicode_compatible class PlotDetails(models.Model): details = models.CharField(max_length=100) plot = models.OneToOneField(Plot, models.CASCADE, null=True, blank=True) @@ -546,7 +519,6 @@ class PlotProxy(Plot): proxy = True -@python_2_unicode_compatible class SecretHideout(models.Model): """ Secret! Not registered with the admin! """ location = models.CharField(max_length=100) @@ -556,7 +528,6 @@ class SecretHideout(models.Model): return self.location -@python_2_unicode_compatible class SuperSecretHideout(models.Model): """ Secret! Not registered with the admin! """ location = models.CharField(max_length=100) @@ -566,7 +537,6 @@ class SuperSecretHideout(models.Model): return self.location -@python_2_unicode_compatible class Bookmark(models.Model): name = models.CharField(max_length=60) tag = GenericRelation(FunkyTag, related_query_name='bookmark') @@ -575,7 +545,6 @@ class Bookmark(models.Model): return self.name -@python_2_unicode_compatible class CyclicOne(models.Model): name = models.CharField(max_length=25) two = models.ForeignKey('CyclicTwo', models.CASCADE) @@ -584,7 +553,6 @@ class CyclicOne(models.Model): return self.name -@python_2_unicode_compatible class CyclicTwo(models.Model): name = models.CharField(max_length=25) one = models.ForeignKey(CyclicOne, models.CASCADE) @@ -593,7 +561,6 @@ class CyclicTwo(models.Model): return self.name -@python_2_unicode_compatible class Topping(models.Model): name = models.CharField(max_length=20) @@ -625,7 +592,6 @@ class Question(models.Model): posted = models.DateField(default=datetime.date.today) -@python_2_unicode_compatible class Answer(models.Model): question = models.ForeignKey(Question, models.PROTECT) answer = models.CharField(max_length=20) @@ -660,7 +626,6 @@ class FoodDelivery(models.Model): unique_together = (("driver", "restaurant"),) -@python_2_unicode_compatible class CoverLetter(models.Model): author = models.CharField(max_length=30) date_written = models.DateField(null=True, blank=True) @@ -679,7 +644,6 @@ class ShortMessage(models.Model): timestamp = models.DateTimeField(null=True, blank=True) -@python_2_unicode_compatible class Telegram(models.Model): title = models.CharField(max_length=30) date_sent = models.DateField(null=True, blank=True) @@ -745,7 +709,6 @@ class AdminOrderedCallable(models.Model): stuff = models.CharField(max_length=200) -@python_2_unicode_compatible class Report(models.Model): title = models.CharField(max_length=100) diff --git a/tests/admin_widgets/models.py b/tests/admin_widgets/models.py index 43aa88e254..fcc86ddeb8 100644 --- a/tests/admin_widgets/models.py +++ b/tests/admin_widgets/models.py @@ -1,13 +1,11 @@ from django.contrib.auth.models import User from django.db import models -from django.utils.encoding import python_2_unicode_compatible class MyFileField(models.FileField): pass -@python_2_unicode_compatible class Member(models.Model): name = models.CharField(max_length=100) birthdate = models.DateTimeField(blank=True, null=True) @@ -18,7 +16,6 @@ class Member(models.Model): return self.name -@python_2_unicode_compatible class Band(models.Model): name = models.CharField(max_length=100) style = models.CharField(max_length=20) @@ -28,7 +25,6 @@ class Band(models.Model): return self.name -@python_2_unicode_compatible class Album(models.Model): band = models.ForeignKey(Band, models.CASCADE) name = models.CharField(max_length=100) @@ -44,7 +40,6 @@ class HiddenInventoryManager(models.Manager): return super(HiddenInventoryManager, self).get_queryset().filter(hidden=False) -@python_2_unicode_compatible class Inventory(models.Model): barcode = models.PositiveIntegerField(unique=True) parent = models.ForeignKey('self', models.SET_NULL, to_field='barcode', blank=True, null=True) @@ -79,7 +74,6 @@ class Event(models.Model): min_age = models.IntegerField(blank=True, null=True) -@python_2_unicode_compatible class Car(models.Model): owner = models.ForeignKey(User, models.CASCADE) make = models.CharField(max_length=30) @@ -134,7 +128,6 @@ class Advisor(models.Model): companies = models.ManyToManyField(Company) -@python_2_unicode_compatible class Student(models.Model): name = models.CharField(max_length=255) @@ -145,7 +138,6 @@ class Student(models.Model): ordering = ('name',) -@python_2_unicode_compatible class School(models.Model): name = models.CharField(max_length=255) students = models.ManyToManyField(Student, related_name='current_schools') @@ -155,7 +147,6 @@ class School(models.Model): return self.name -@python_2_unicode_compatible class Profile(models.Model): user = models.ForeignKey('auth.User', models.CASCADE, to_field='username') diff --git a/tests/aggregation/models.py b/tests/aggregation/models.py index 37421dbb81..fd441fe51d 100644 --- a/tests/aggregation/models.py +++ b/tests/aggregation/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=100) age = models.IntegerField() @@ -12,7 +10,6 @@ class Author(models.Model): return self.name -@python_2_unicode_compatible class Publisher(models.Model): name = models.CharField(max_length=255) num_awards = models.IntegerField() @@ -22,7 +19,6 @@ class Publisher(models.Model): return self.name -@python_2_unicode_compatible class Book(models.Model): isbn = models.CharField(max_length=9) name = models.CharField(max_length=255) @@ -38,7 +34,6 @@ class Book(models.Model): return self.name -@python_2_unicode_compatible class Store(models.Model): name = models.CharField(max_length=255) books = models.ManyToManyField(Book) diff --git a/tests/aggregation_regress/models.py b/tests/aggregation_regress/models.py index a9ab1cbdce..3498cbf168 100644 --- a/tests/aggregation_regress/models.py +++ b/tests/aggregation_regress/models.py @@ -3,10 +3,8 @@ from django.contrib.contenttypes.fields import ( ) from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=100) age = models.IntegerField() @@ -16,7 +14,6 @@ class Author(models.Model): return self.name -@python_2_unicode_compatible class Publisher(models.Model): name = models.CharField(max_length=255) num_awards = models.IntegerField() @@ -32,7 +29,6 @@ class ItemTag(models.Model): content_object = GenericForeignKey('content_type', 'object_id') -@python_2_unicode_compatible class Book(models.Model): isbn = models.CharField(max_length=9) name = models.CharField(max_length=255) @@ -52,7 +48,6 @@ class Book(models.Model): return self.name -@python_2_unicode_compatible class Store(models.Model): name = models.CharField(max_length=255) books = models.ManyToManyField(Book) @@ -83,7 +78,6 @@ class WithManualPK(models.Model): id = models.IntegerField(primary_key=True) -@python_2_unicode_compatible class HardbackBook(Book): weight = models.FloatField() diff --git a/tests/annotations/models.py b/tests/annotations/models.py index 79648ffd96..4aeda3c093 100644 --- a/tests/annotations/models.py +++ b/tests/annotations/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=100) age = models.IntegerField() @@ -12,7 +10,6 @@ class Author(models.Model): return self.name -@python_2_unicode_compatible class Publisher(models.Model): name = models.CharField(max_length=255) num_awards = models.IntegerField() @@ -21,7 +18,6 @@ class Publisher(models.Model): return self.name -@python_2_unicode_compatible class Book(models.Model): isbn = models.CharField(max_length=9) name = models.CharField(max_length=255) @@ -37,7 +33,6 @@ class Book(models.Model): return self.name -@python_2_unicode_compatible class Store(models.Model): name = models.CharField(max_length=255) books = models.ManyToManyField(Book) @@ -48,7 +43,6 @@ class Store(models.Model): return self.name -@python_2_unicode_compatible class DepartmentStore(Store): chain = models.CharField(max_length=255) @@ -56,7 +50,6 @@ class DepartmentStore(Store): return '%s - %s ' % (self.chain, self.name) -@python_2_unicode_compatible class Employee(models.Model): # The order of these fields matter, do not change. Certain backends # rely on field ordering to perform database conversions, and this @@ -72,7 +65,6 @@ class Employee(models.Model): return '%s %s' % (self.first_name, self.last_name) -@python_2_unicode_compatible class Company(models.Model): name = models.CharField(max_length=200) motto = models.CharField(max_length=200, null=True, blank=True) @@ -85,7 +77,6 @@ class Company(models.Model): ) -@python_2_unicode_compatible class Ticket(models.Model): active_at = models.DateTimeField() duration = models.DurationField() diff --git a/tests/auth_tests/models/custom_permissions.py b/tests/auth_tests/models/custom_permissions.py index a6c5a1e96a..73c10e5040 100644 --- a/tests/auth_tests/models/custom_permissions.py +++ b/tests/auth_tests/models/custom_permissions.py @@ -5,7 +5,6 @@ includes everything that is needed to interact with the ModelBackend. """ from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin from django.db import models -from django.utils.encoding import python_2_unicode_compatible from .custom_user import CustomUserManager, RemoveGroupsAndPermissions @@ -19,7 +18,6 @@ class CustomPermissionsUserManager(CustomUserManager): with RemoveGroupsAndPermissions(): - @python_2_unicode_compatible class CustomPermissionsUser(AbstractBaseUser, PermissionsMixin): email = models.EmailField(verbose_name='email address', max_length=255, unique=True) date_of_birth = models.DateField() diff --git a/tests/auth_tests/models/custom_user.py b/tests/auth_tests/models/custom_user.py index fac51064ba..049ae85e5c 100644 --- a/tests/auth_tests/models/custom_user.py +++ b/tests/auth_tests/models/custom_user.py @@ -3,7 +3,6 @@ from django.contrib.auth.models import ( PermissionsMixin, UserManager, ) from django.db import models -from django.utils.encoding import python_2_unicode_compatible # The custom user uses email as the unique identifier, and requires @@ -33,7 +32,6 @@ class CustomUserManager(BaseUserManager): return u -@python_2_unicode_compatible class CustomUser(AbstractBaseUser): email = models.EmailField(verbose_name='email address', max_length=255, unique=True) is_active = models.BooleanField(default=True) diff --git a/tests/backends/models.py b/tests/backends/models.py index 18423e1276..6277e52525 100644 --- a/tests/backends/models.py +++ b/tests/backends/models.py @@ -3,10 +3,8 @@ from django.contrib.contenttypes.fields import ( ) from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Square(models.Model): root = models.IntegerField() square = models.PositiveIntegerField() @@ -15,7 +13,6 @@ class Square(models.Model): return "%s ** 2 == %s" % (self.root, self.square) -@python_2_unicode_compatible class Person(models.Model): first_name = models.CharField(max_length=20) last_name = models.CharField(max_length=20) @@ -52,7 +49,6 @@ class Post(models.Model): db_table = 'CaseSensitive_Post' -@python_2_unicode_compatible class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) @@ -66,7 +62,6 @@ class ReporterProxy(Reporter): proxy = True -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateField() @@ -82,7 +77,6 @@ class Article(models.Model): return self.headline -@python_2_unicode_compatible class Item(models.Model): name = models.CharField(max_length=30) date = models.DateField() @@ -93,7 +87,6 @@ class Item(models.Model): return self.name -@python_2_unicode_compatible class Object(models.Model): related_objects = models.ManyToManyField("self", db_constraint=False, symmetrical=False) @@ -101,7 +94,6 @@ class Object(models.Model): return str(self.id) -@python_2_unicode_compatible class ObjectReference(models.Model): obj = models.ForeignKey(Object, models.CASCADE, db_constraint=False) diff --git a/tests/basic/models.py b/tests/basic/models.py index a6010f1291..c08b147ac4 100644 --- a/tests/basic/models.py +++ b/tests/basic/models.py @@ -4,10 +4,8 @@ Bare-bones model This is a basic model with only two non-primary-key fields. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100, default='Default headline') pub_date = models.DateTimeField() @@ -25,7 +23,6 @@ class ArticleSelectOnSave(Article): select_on_save = True -@python_2_unicode_compatible class SelfRef(models.Model): selfref = models.ForeignKey( 'self', diff --git a/tests/choices/models.py b/tests/choices/models.py index 3384947f93..de68118386 100644 --- a/tests/choices/models.py +++ b/tests/choices/models.py @@ -10,7 +10,6 @@ field. This method returns the "human-readable" value of the field. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible GENDER_CHOICES = ( ('M', 'Male'), @@ -18,7 +17,6 @@ GENDER_CHOICES = ( ) -@python_2_unicode_compatible class Person(models.Model): name = models.CharField(max_length=20) gender = models.CharField(max_length=1, choices=GENDER_CHOICES) diff --git a/tests/contenttypes_tests/models.py b/tests/contenttypes_tests/models.py index 1640ee3b8c..0aa8bbf0bc 100644 --- a/tests/contenttypes_tests/models.py +++ b/tests/contenttypes_tests/models.py @@ -4,11 +4,9 @@ from django.contrib.contenttypes.fields import ( from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import SiteManager from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.http import urlquote -@python_2_unicode_compatible class Site(models.Model): domain = models.CharField(max_length=100) objects = SiteManager() @@ -17,7 +15,6 @@ class Site(models.Model): return self.domain -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=100) @@ -28,7 +25,6 @@ class Author(models.Model): return '/authors/%s/' % self.id -@python_2_unicode_compatible class Article(models.Model): title = models.CharField(max_length=100) slug = models.SlugField() @@ -39,7 +35,6 @@ class Article(models.Model): return self.title -@python_2_unicode_compatible class SchemeIncludedURL(models.Model): url = models.URLField(max_length=100) @@ -59,7 +54,6 @@ class ProxyModel(ConcreteModel): proxy = True -@python_2_unicode_compatible class FooWithoutUrl(models.Model): """ Fake model not defining ``get_absolute_url`` for @@ -95,7 +89,6 @@ class Question(models.Model): answer_set = GenericRelation('Answer') -@python_2_unicode_compatible class Answer(models.Model): text = models.CharField(max_length=200) content_type = models.ForeignKey(ContentType, models.CASCADE) @@ -109,7 +102,6 @@ class Answer(models.Model): return self.text -@python_2_unicode_compatible class Post(models.Model): """An ordered tag on an item.""" title = models.CharField(max_length=200) @@ -125,7 +117,6 @@ class Post(models.Model): return self.title -@python_2_unicode_compatible class ModelWithNullFKToSite(models.Model): title = models.CharField(max_length=200) site = models.ForeignKey(Site, null=True, on_delete=models.CASCADE) diff --git a/tests/custom_columns/models.py b/tests/custom_columns/models.py index d5f5217ba5..32d55af9f3 100644 --- a/tests/custom_columns/models.py +++ b/tests/custom_columns/models.py @@ -16,10 +16,8 @@ from the default generated name, use the ``db_table`` parameter on the """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Author(models.Model): Author_ID = models.AutoField(primary_key=True, db_column='Author ID') first_name = models.CharField(max_length=30, db_column='firstname') @@ -33,7 +31,6 @@ class Author(models.Model): ordering = ('last_name', 'first_name') -@python_2_unicode_compatible class Article(models.Model): Article_ID = models.AutoField(primary_key=True, db_column='Article ID') headline = models.CharField(max_length=100) diff --git a/tests/custom_lookups/models.py b/tests/custom_lookups/models.py index 97979dd953..071858cd3d 100644 --- a/tests/custom_lookups/models.py +++ b/tests/custom_lookups/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=20) age = models.IntegerField(null=True) @@ -17,7 +15,6 @@ class Article(models.Model): author = models.ForeignKey(Author, on_delete=models.CASCADE) -@python_2_unicode_compatible class MySQLUnixTimestamp(models.Model): timestamp = models.PositiveIntegerField() diff --git a/tests/custom_managers/models.py b/tests/custom_managers/models.py index 1d47869af9..c5f224ea51 100644 --- a/tests/custom_managers/models.py +++ b/tests/custom_managers/models.py @@ -13,7 +13,6 @@ from django.contrib.contenttypes.fields import ( GenericForeignKey, GenericRelation, ) from django.db import models -from django.utils.encoding import python_2_unicode_compatible class PersonManager(models.Manager): @@ -86,7 +85,6 @@ class BoringPeopleManager(models.Manager): return super(BoringPeopleManager, self).get_queryset().filter(fun=False) -@python_2_unicode_compatible class Person(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) @@ -109,7 +107,6 @@ class Person(models.Model): return "%s %s" % (self.first_name, self.last_name) -@python_2_unicode_compatible class FunPerson(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) @@ -130,7 +127,6 @@ class FunPerson(models.Model): return "%s %s" % (self.first_name, self.last_name) -@python_2_unicode_compatible class Book(models.Model): title = models.CharField(max_length=50) author = models.CharField(max_length=30) @@ -158,7 +154,6 @@ class FastCarManager(models.Manager): return super(FastCarManager, self).get_queryset().filter(top_speed__gt=150) -@python_2_unicode_compatible class Car(models.Model): name = models.CharField(max_length=10) mileage = models.IntegerField() @@ -187,7 +182,6 @@ class RestrictedManager(models.Manager): return super(RestrictedManager, self).get_queryset().filter(is_public=True) -@python_2_unicode_compatible class RelatedModel(models.Model): name = models.CharField(max_length=50) @@ -195,7 +189,6 @@ class RelatedModel(models.Model): return self.name -@python_2_unicode_compatible class RestrictedModel(models.Model): name = models.CharField(max_length=50) is_public = models.BooleanField(default=False) @@ -208,7 +201,6 @@ class RestrictedModel(models.Model): return self.name -@python_2_unicode_compatible class OneToOneRestrictedModel(models.Model): name = models.CharField(max_length=50) is_public = models.BooleanField(default=False) diff --git a/tests/custom_methods/models.py b/tests/custom_methods/models.py index 7def1d6017..f44d1b8265 100644 --- a/tests/custom_methods/models.py +++ b/tests/custom_methods/models.py @@ -7,10 +7,8 @@ Any method you add to a model will be available to instances. import datetime from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateField() diff --git a/tests/custom_pk/fields.py b/tests/custom_pk/fields.py index 3779fc6c43..eb63f66679 100644 --- a/tests/custom_pk/fields.py +++ b/tests/custom_pk/fields.py @@ -3,10 +3,8 @@ import string from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class MyWrapper(object): def __init__(self, value): self.value = value diff --git a/tests/custom_pk/models.py b/tests/custom_pk/models.py index e0a318468c..0b272c1135 100644 --- a/tests/custom_pk/models.py +++ b/tests/custom_pk/models.py @@ -6,12 +6,10 @@ this behavior by explicitly adding ``primary_key=True`` to a field. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible from .fields import MyAutoField -@python_2_unicode_compatible class Employee(models.Model): employee_code = models.IntegerField(primary_key=True, db_column='code') first_name = models.CharField(max_length=20) @@ -24,7 +22,6 @@ class Employee(models.Model): return "%s %s" % (self.first_name, self.last_name) -@python_2_unicode_compatible class Business(models.Model): name = models.CharField(max_length=20, primary_key=True) employees = models.ManyToManyField(Employee) @@ -36,7 +33,6 @@ class Business(models.Model): return self.name -@python_2_unicode_compatible class Bar(models.Model): id = MyAutoField(primary_key=True, db_index=True) diff --git a/tests/datatypes/models.py b/tests/datatypes/models.py index cabe5297bd..570b2ba8e0 100644 --- a/tests/datatypes/models.py +++ b/tests/datatypes/models.py @@ -4,10 +4,8 @@ types, which in the past were problematic for some database backends. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Donut(models.Model): name = models.CharField(max_length=100) is_frosted = models.BooleanField(default=False) diff --git a/tests/dates/models.py b/tests/dates/models.py index 978cf44e95..74f9db28ad 100644 --- a/tests/dates/models.py +++ b/tests/dates/models.py @@ -1,9 +1,7 @@ from django.db import models from django.utils import timezone -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Article(models.Model): title = models.CharField(max_length=100) pub_date = models.DateField() @@ -15,7 +13,6 @@ class Article(models.Model): return self.title -@python_2_unicode_compatible class Comment(models.Model): article = models.ForeignKey(Article, models.CASCADE, related_name="comments") text = models.TextField() diff --git a/tests/datetimes/models.py b/tests/datetimes/models.py index 4d2ad9ac7a..c8b64ae52a 100644 --- a/tests/datetimes/models.py +++ b/tests/datetimes/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Article(models.Model): title = models.CharField(max_length=100) pub_date = models.DateTimeField() @@ -14,7 +12,6 @@ class Article(models.Model): return self.title -@python_2_unicode_compatible class Comment(models.Model): article = models.ForeignKey(Article, models.CASCADE, related_name="comments") text = models.TextField() diff --git a/tests/db_functions/models.py b/tests/db_functions/models.py index 8d0fbc6deb..bfcdb7759e 100644 --- a/tests/db_functions/models.py +++ b/tests/db_functions/models.py @@ -2,10 +2,8 @@ Tests for built in Function expressions. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=50) alias = models.CharField(max_length=50, null=True, blank=True) @@ -16,7 +14,6 @@ class Author(models.Model): return self.name -@python_2_unicode_compatible class Article(models.Model): authors = models.ManyToManyField(Author, related_name='articles') title = models.CharField(max_length=50) @@ -31,7 +28,6 @@ class Article(models.Model): return self.title -@python_2_unicode_compatible class Fan(models.Model): name = models.CharField(max_length=50) age = models.PositiveSmallIntegerField(default=30) @@ -41,7 +37,6 @@ class Fan(models.Model): return self.name -@python_2_unicode_compatible class DTModel(models.Model): name = models.CharField(max_length=32) start_datetime = models.DateTimeField(null=True, blank=True) diff --git a/tests/defer/models.py b/tests/defer/models.py index b36b173501..dbdce0b025 100644 --- a/tests/defer/models.py +++ b/tests/defer/models.py @@ -3,7 +3,6 @@ Tests for defer() and only(). """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible class Secondary(models.Model): @@ -11,7 +10,6 @@ class Secondary(models.Model): second = models.CharField(max_length=50) -@python_2_unicode_compatible class Primary(models.Model): name = models.CharField(max_length=50) value = models.CharField(max_length=50) diff --git a/tests/defer_regress/models.py b/tests/defer_regress/models.py index a73f539ba1..55eac8c537 100644 --- a/tests/defer_regress/models.py +++ b/tests/defer_regress/models.py @@ -3,10 +3,8 @@ Regression tests for defer() / only() behavior. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Item(models.Model): name = models.CharField(max_length=15) text = models.TextField(default="xyzzy") @@ -31,7 +29,6 @@ class Child(models.Model): value = models.IntegerField() -@python_2_unicode_compatible class Leaf(models.Model): name = models.CharField(max_length=10) child = models.ForeignKey(Child, models.CASCADE) @@ -52,7 +49,6 @@ class Proxy(Item): proxy = True -@python_2_unicode_compatible class SimpleItem(models.Model): name = models.CharField(max_length=15) value = models.IntegerField() diff --git a/tests/delete/models.py b/tests/delete/models.py index 4064173df4..2fc5ebe217 100644 --- a/tests/delete/models.py +++ b/tests/delete/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class R(models.Model): is_default = models.BooleanField(default=False) diff --git a/tests/distinct_on_fields/models.py b/tests/distinct_on_fields/models.py index a4164724f3..06c4f349c0 100644 --- a/tests/distinct_on_fields/models.py +++ b/tests/distinct_on_fields/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Tag(models.Model): name = models.CharField(max_length=10) parent = models.ForeignKey( @@ -20,7 +18,6 @@ class Tag(models.Model): return self.name -@python_2_unicode_compatible class Celebrity(models.Model): name = models.CharField("Name", max_length=20) greatest_fan = models.ForeignKey( @@ -38,7 +35,6 @@ class Fan(models.Model): fan_of = models.ForeignKey(Celebrity, models.CASCADE) -@python_2_unicode_compatible class Staff(models.Model): id = models.IntegerField(primary_key=True) name = models.CharField(max_length=50) @@ -50,7 +46,6 @@ class Staff(models.Model): return self.name -@python_2_unicode_compatible class StaffTag(models.Model): staff = models.ForeignKey(Staff, models.CASCADE) tag = models.ForeignKey(Tag, models.CASCADE) diff --git a/tests/expressions/models.py b/tests/expressions/models.py index e2bfb8ef67..51042c845b 100644 --- a/tests/expressions/models.py +++ b/tests/expressions/models.py @@ -3,10 +3,8 @@ Tests for F() query expression syntax. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Employee(models.Model): firstname = models.CharField(max_length=50) lastname = models.CharField(max_length=50) @@ -16,7 +14,6 @@ class Employee(models.Model): return '%s %s' % (self.firstname, self.lastname) -@python_2_unicode_compatible class Company(models.Model): name = models.CharField(max_length=100) num_employees = models.PositiveIntegerField() @@ -35,7 +32,6 @@ class Company(models.Model): return self.name -@python_2_unicode_compatible class Number(models.Model): integer = models.BigIntegerField(db_column='the_integer') float = models.FloatField(null=True, db_column='the_float') @@ -59,7 +55,6 @@ class Experiment(models.Model): return self.end - self.start -@python_2_unicode_compatible class Result(models.Model): experiment = models.ForeignKey(Experiment, models.CASCADE) result_time = models.DateTimeField() @@ -68,7 +63,6 @@ class Result(models.Model): return "Result at %s" % self.result_time -@python_2_unicode_compatible class Time(models.Model): time = models.TimeField(null=True) @@ -76,7 +70,6 @@ class Time(models.Model): return "%s" % self.time -@python_2_unicode_compatible class SimulationRun(models.Model): start = models.ForeignKey(Time, models.CASCADE, null=True, related_name='+') end = models.ForeignKey(Time, models.CASCADE, null=True, related_name='+') @@ -86,7 +79,6 @@ class SimulationRun(models.Model): return "%s (%s to %s)" % (self.midpoint, self.start, self.end) -@python_2_unicode_compatible class UUID(models.Model): uuid = models.UUIDField(null=True) diff --git a/tests/expressions_case/models.py b/tests/expressions_case/models.py index 8c2eaac399..7c1a8d75b7 100644 --- a/tests/expressions_case/models.py +++ b/tests/expressions_case/models.py @@ -1,5 +1,4 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible try: from PIL import Image @@ -7,7 +6,6 @@ except ImportError: Image = None -@python_2_unicode_compatible class CaseTestModel(models.Model): integer = models.IntegerField() integer2 = models.IntegerField(null=True) @@ -42,7 +40,6 @@ class CaseTestModel(models.Model): return "%i, %s" % (self.integer, self.string) -@python_2_unicode_compatible class O2OCaseTestModel(models.Model): o2o = models.OneToOneField(CaseTestModel, models.CASCADE, related_name='o2o_rel') integer = models.IntegerField() @@ -51,7 +48,6 @@ class O2OCaseTestModel(models.Model): return "%i, %s" % (self.id, self.o2o) -@python_2_unicode_compatible class FKCaseTestModel(models.Model): fk = models.ForeignKey(CaseTestModel, models.CASCADE, related_name='fk_rel') integer = models.IntegerField() @@ -60,7 +56,6 @@ class FKCaseTestModel(models.Model): return "%i, %s" % (self.id, self.fk) -@python_2_unicode_compatible class Client(models.Model): REGULAR = 'R' GOLD = 'G' diff --git a/tests/extra_regress/models.py b/tests/extra_regress/models.py index b271d8701f..1a5c2dedeb 100644 --- a/tests/extra_regress/models.py +++ b/tests/extra_regress/models.py @@ -3,10 +3,8 @@ import datetime from django.contrib.auth.models import User from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class RevisionableModel(models.Model): base = models.ForeignKey('self', models.SET_NULL, null=True) title = models.CharField(blank=True, max_length=255) @@ -34,7 +32,6 @@ class Order(models.Model): text = models.TextField() -@python_2_unicode_compatible class TestObject(models.Model): first = models.CharField(max_length=20) second = models.CharField(max_length=20) diff --git a/tests/field_defaults/models.py b/tests/field_defaults/models.py index 71129cb5c7..e125dd1c4f 100644 --- a/tests/field_defaults/models.py +++ b/tests/field_defaults/models.py @@ -12,10 +12,8 @@ field. from datetime import datetime from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100, default='Default headline') pub_date = models.DateTimeField(default=datetime.now) diff --git a/tests/fixtures/models.py b/tests/fixtures/models.py index 78161c8474..b3ebb8fc5d 100644 --- a/tests/fixtures/models.py +++ b/tests/fixtures/models.py @@ -14,10 +14,8 @@ from django.contrib.auth.models import Permission from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Category(models.Model): title = models.CharField(max_length=100) description = models.TextField() @@ -29,7 +27,6 @@ class Category(models.Model): ordering = ('title',) -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100, default='Default headline') pub_date = models.DateTimeField() @@ -41,7 +38,6 @@ class Article(models.Model): ordering = ('-pub_date', 'headline') -@python_2_unicode_compatible class Blog(models.Model): name = models.CharField(max_length=100) featured = models.ForeignKey(Article, models.CASCADE, related_name='fixtures_featured_set') @@ -52,7 +48,6 @@ class Blog(models.Model): return self.name -@python_2_unicode_compatible class Tag(models.Model): name = models.CharField(max_length=100) tagged_type = models.ForeignKey(ContentType, models.CASCADE, related_name="fixtures_tag_set") @@ -69,7 +64,6 @@ class PersonManager(models.Manager): return self.get(name=name) -@python_2_unicode_compatible class Person(models.Model): objects = PersonManager() name = models.CharField(max_length=100) @@ -99,7 +93,6 @@ class ProxySpy(Spy): proxy = True -@python_2_unicode_compatible class Visa(models.Model): person = models.ForeignKey(Person, models.CASCADE) permissions = models.ManyToManyField(Permission, blank=True) @@ -109,7 +102,6 @@ class Visa(models.Model): ', '.join(p.name for p in self.permissions.all())) -@python_2_unicode_compatible class Book(models.Model): name = models.CharField(max_length=100) authors = models.ManyToManyField(Person) diff --git a/tests/fixtures_model_package/models/__init__.py b/tests/fixtures_model_package/models/__init__.py index 63d73f83f9..5160f354e6 100644 --- a/tests/fixtures_model_package/models/__init__.py +++ b/tests/fixtures_model_package/models/__init__.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100, default='Default headline') pub_date = models.DateTimeField() diff --git a/tests/fixtures_regress/models.py b/tests/fixtures_regress/models.py index 63e883f7d5..a631fa44d1 100644 --- a/tests/fixtures_regress/models.py +++ b/tests/fixtures_regress/models.py @@ -1,10 +1,8 @@ from django.contrib.auth.models import User from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Animal(models.Model): name = models.CharField(max_length=150) latin_name = models.CharField(max_length=150) @@ -26,7 +24,6 @@ class Plant(models.Model): db_table = "Fixtures_regress_plant" -@python_2_unicode_compatible class Stuff(models.Model): name = models.CharField(max_length=20, null=True) owner = models.ForeignKey(User, models.SET_NULL, null=True) @@ -80,7 +77,6 @@ class Feature(CommonFeature): # Models to regression test #11428 -@python_2_unicode_compatible class Widget(models.Model): name = models.CharField(max_length=255) @@ -102,7 +98,6 @@ class TestManager(models.Manager): return self.get(name=key) -@python_2_unicode_compatible class Store(models.Model): objects = TestManager() name = models.CharField(max_length=255) @@ -118,7 +113,6 @@ class Store(models.Model): return (self.name,) -@python_2_unicode_compatible class Person(models.Model): objects = TestManager() name = models.CharField(max_length=255) @@ -136,7 +130,6 @@ class Person(models.Model): natural_key.dependencies = ['fixtures_regress.store'] -@python_2_unicode_compatible class Book(models.Model): name = models.CharField(max_length=255) author = models.ForeignKey(Person, models.CASCADE) @@ -158,7 +151,6 @@ class NKManager(models.Manager): return self.get(data=data) -@python_2_unicode_compatible class NKChild(Parent): data = models.CharField(max_length=10, unique=True) objects = NKManager() @@ -170,7 +162,6 @@ class NKChild(Parent): return 'NKChild %s:%s' % (self.name, self.data) -@python_2_unicode_compatible class RefToNKChild(models.Model): text = models.CharField(max_length=10) nk_fk = models.ForeignKey(NKChild, models.CASCADE, related_name='ref_fks') @@ -250,7 +241,6 @@ class M2MToSelf(models.Model): parent = models.ManyToManyField("self", blank=True) -@python_2_unicode_compatible class BaseNKModel(models.Model): """ Base model with a natural_key and a manager with `get_by_natural_key` diff --git a/tests/foreign_object/models/article.py b/tests/foreign_object/models/article.py index 6e16784d2c..e5c0c1f673 100644 --- a/tests/foreign_object/models/article.py +++ b/tests/foreign_object/models/article.py @@ -1,6 +1,5 @@ from django.db import models from django.db.models.fields.related import ForwardManyToOneDescriptor -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import get_language @@ -49,7 +48,6 @@ class ActiveTranslationFieldWithQ(ActiveTranslationField): return models.Q(lang=get_language()) -@python_2_unicode_compatible class Article(models.Model): active_translation = ActiveTranslationField( 'ArticleTranslation', diff --git a/tests/foreign_object/models/empty_join.py b/tests/foreign_object/models/empty_join.py index 28f3006c94..5b58ffdafc 100644 --- a/tests/foreign_object/models/empty_join.py +++ b/tests/foreign_object/models/empty_join.py @@ -4,7 +4,6 @@ from django.db.models.fields.related import ( ) from django.db.models.lookups import StartsWith from django.db.models.query_utils import PathInfo -from django.utils.encoding import python_2_unicode_compatible class CustomForeignObjectRel(ForeignObjectRel): @@ -78,7 +77,6 @@ class BrokenContainsRelation(StartsWithRelation): return None -@python_2_unicode_compatible class SlugPage(models.Model): slug = models.CharField(max_length=20, unique=True) descendants = StartsWithRelation( diff --git a/tests/foreign_object/models/person.py b/tests/foreign_object/models/person.py index 26d88007fb..a41d9d96d9 100644 --- a/tests/foreign_object/models/person.py +++ b/tests/foreign_object/models/person.py @@ -1,10 +1,8 @@ import datetime from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Country(models.Model): # Table Column Fields name = models.CharField(max_length=50) @@ -13,7 +11,6 @@ class Country(models.Model): return self.name -@python_2_unicode_compatible class Person(models.Model): # Table Column Fields name = models.CharField(max_length=128) @@ -35,7 +32,6 @@ class Person(models.Model): return self.name -@python_2_unicode_compatible class Group(models.Model): # Table Column Fields name = models.CharField(max_length=128) @@ -49,7 +45,6 @@ class Group(models.Model): return self.name -@python_2_unicode_compatible class Membership(models.Model): # Table Column Fields membership_country = models.ForeignKey(Country, models.CASCADE) diff --git a/tests/forms_tests/models.py b/tests/forms_tests/models.py index be1b66bce6..fa63d08fd1 100644 --- a/tests/forms_tests/models.py +++ b/tests/forms_tests/models.py @@ -4,7 +4,6 @@ import tempfile from django.core.files.storage import FileSystemStorage from django.db import models -from django.utils.encoding import python_2_unicode_compatible callable_default_counter = itertools.count() @@ -55,7 +54,6 @@ class ChoiceModel(models.Model): null=True) -@python_2_unicode_compatible class ChoiceOptionModel(models.Model): """Destination for ChoiceFieldModel's ForeignKey. Can't reuse ChoiceModel because error_message tests require that it have no instances.""" @@ -132,7 +130,6 @@ class FileModel(models.Model): file = models.FileField(storage=temp_storage, upload_to='tests') -@python_2_unicode_compatible class Group(models.Model): name = models.CharField(max_length=10) diff --git a/tests/forms_tests/tests/test_error_messages.py b/tests/forms_tests/tests/test_error_messages.py index eb7debf936..10c7a92f7d 100644 --- a/tests/forms_tests/tests/test_error_messages.py +++ b/tests/forms_tests/tests/test_error_messages.py @@ -8,7 +8,6 @@ from django.forms import ( ) from django.template import Context, Template from django.test import SimpleTestCase, TestCase -from django.utils.encoding import python_2_unicode_compatible from django.utils.safestring import mark_safe from ..models import ChoiceModel @@ -216,7 +215,6 @@ class FormsErrorMessagesTestCase(SimpleTestCase, AssertFormErrorsMixin): def clean(self): raise ValidationError("I like to be awkward.") - @python_2_unicode_compatible class CustomErrorList(utils.ErrorList): def __str__(self): return self.as_divs() diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index b8ced2425c..dacd7739d3 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -21,7 +21,7 @@ from django.template import Context, Template from django.test import SimpleTestCase from django.test.utils import str_prefix from django.utils.datastructures import MultiValueDict -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.html import format_html from django.utils.safestring import SafeData, mark_safe @@ -3375,7 +3375,6 @@ Good luck picking a username that doesn't already exist.

) def test_errorlist_override(self): - @python_2_unicode_compatible class DivErrorList(ErrorList): def __str__(self): return self.as_divs() diff --git a/tests/forms_tests/tests/test_utils.py b/tests/forms_tests/tests/test_utils.py index d0dfaad370..f06b60a620 100644 --- a/tests/forms_tests/tests/test_utils.py +++ b/tests/forms_tests/tests/test_utils.py @@ -4,7 +4,7 @@ from django.core.exceptions import ValidationError from django.forms.utils import ErrorDict, ErrorList, flatatt from django.test import SimpleTestCase from django.utils import six -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy @@ -101,7 +101,6 @@ class FormsUtilsTestCase(SimpleTestCase): '' ) - @python_2_unicode_compatible class VeryBadError: def __str__(self): return "A very bad error." diff --git a/tests/forms_tests/widget_tests/test_clearablefileinput.py b/tests/forms_tests/widget_tests/test_clearablefileinput.py index 3727d0c0df..dd7f04d0ac 100644 --- a/tests/forms_tests/widget_tests/test_clearablefileinput.py +++ b/tests/forms_tests/widget_tests/test_clearablefileinput.py @@ -1,11 +1,9 @@ from django.core.files.uploadedfile import SimpleUploadedFile from django.forms import ClearableFileInput -from django.utils.encoding import python_2_unicode_compatible from .base import WidgetTest -@python_2_unicode_compatible class FakeFieldFile(object): """ Quacks like a FieldFile (has a .url and unicode representation), but @@ -39,7 +37,6 @@ class ClearableFileInputTest(WidgetTest): A ClearableFileInput should escape name, filename, and URL when rendering HTML (#15182). """ - @python_2_unicode_compatible class StrangeFieldFile(object): url = "something?chapter=1§=2©=3&lang=en" @@ -110,7 +107,6 @@ class ClearableFileInputTest(WidgetTest): A ClearableFileInput should not mask exceptions produced while checking that it has a value. """ - @python_2_unicode_compatible class FailingURLFieldFile(object): @property def url(self): @@ -123,7 +119,6 @@ class ClearableFileInputTest(WidgetTest): self.widget.render('myfile', FailingURLFieldFile()) def test_url_as_property(self): - @python_2_unicode_compatible class URLFieldFile(object): @property def url(self): @@ -136,7 +131,6 @@ class ClearableFileInputTest(WidgetTest): self.assertInHTML('value', html) def test_return_false_if_url_does_not_exists(self): - @python_2_unicode_compatible class NoURLFieldFile(object): def __str__(self): return 'value' diff --git a/tests/from_db_value/models.py b/tests/from_db_value/models.py index aa62b1f567..fae9565a02 100644 --- a/tests/from_db_value/models.py +++ b/tests/from_db_value/models.py @@ -1,7 +1,6 @@ import decimal from django.db import models -from django.utils.encoding import python_2_unicode_compatible class Cash(decimal.Decimal): @@ -24,7 +23,6 @@ class CashField(models.DecimalField): return cash -@python_2_unicode_compatible class CashModel(models.Model): cash = CashField() diff --git a/tests/generic_inline_admin/models.py b/tests/generic_inline_admin/models.py index e981612bd8..96cb6fb5a3 100644 --- a/tests/generic_inline_admin/models.py +++ b/tests/generic_inline_admin/models.py @@ -3,7 +3,6 @@ from django.contrib.contenttypes.fields import ( ) from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible class Episode(models.Model): @@ -12,7 +11,6 @@ class Episode(models.Model): author = models.CharField(max_length=100, blank=True) -@python_2_unicode_compatible class Media(models.Model): """ Media that can associated to any object. diff --git a/tests/generic_relations/models.py b/tests/generic_relations/models.py index f1748b7433..a2f68ff05a 100644 --- a/tests/generic_relations/models.py +++ b/tests/generic_relations/models.py @@ -14,10 +14,8 @@ from django.contrib.contenttypes.fields import ( ) from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class TaggedItem(models.Model): """A tag on an item.""" tag = models.SlugField() @@ -46,7 +44,6 @@ class AbstractComparison(models.Model): first_obj = GenericForeignKey(ct_field="content_type1", fk_field="object_id1") -@python_2_unicode_compatible class Comparison(AbstractComparison): """ A model that tests having multiple GenericForeignKeys. One is defined @@ -61,7 +58,6 @@ class Comparison(AbstractComparison): return "%s is %s than %s" % (self.first_obj, self.comparative, self.other_obj) -@python_2_unicode_compatible class Animal(models.Model): common_name = models.CharField(max_length=150) latin_name = models.CharField(max_length=150) @@ -75,7 +71,6 @@ class Animal(models.Model): return self.common_name -@python_2_unicode_compatible class Vegetable(models.Model): name = models.CharField(max_length=150) is_yucky = models.BooleanField(default=True) @@ -90,7 +85,6 @@ class Carrot(Vegetable): pass -@python_2_unicode_compatible class Mineral(models.Model): name = models.CharField(max_length=150) hardness = models.PositiveSmallIntegerField() diff --git a/tests/generic_relations_regress/models.py b/tests/generic_relations_regress/models.py index eb4f645d34..d9cf692b75 100644 --- a/tests/generic_relations_regress/models.py +++ b/tests/generic_relations_regress/models.py @@ -4,14 +4,12 @@ from django.contrib.contenttypes.fields import ( from django.contrib.contenttypes.models import ContentType from django.db import models from django.db.models.deletion import ProtectedError -from django.utils.encoding import python_2_unicode_compatible __all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address', 'CharLink', 'TextLink', 'OddRelation1', 'OddRelation2', 'Contact', 'Organization', 'Note', 'Company') -@python_2_unicode_compatible class Link(models.Model): content_type = models.ForeignKey(ContentType, models.CASCADE) object_id = models.PositiveIntegerField() @@ -21,7 +19,6 @@ class Link(models.Model): return "Link to %s id=%s" % (self.content_type, self.object_id) -@python_2_unicode_compatible class Place(models.Model): name = models.CharField(max_length=100) links = GenericRelation(Link) @@ -30,13 +27,11 @@ class Place(models.Model): return "Place: %s" % self.name -@python_2_unicode_compatible class Restaurant(Place): def __str__(self): return "Restaurant: %s" % self.name -@python_2_unicode_compatible class Address(models.Model): street = models.CharField(max_length=80) city = models.CharField(max_length=50) @@ -50,7 +45,6 @@ class Address(models.Model): return '%s %s, %s %s' % (self.street, self.city, self.state, self.zipcode) -@python_2_unicode_compatible class Person(models.Model): account = models.IntegerField(primary_key=True) name = models.CharField(max_length=128) @@ -99,7 +93,6 @@ class Organization(models.Model): contacts = models.ManyToManyField(Contact, related_name='organizations') -@python_2_unicode_compatible class Company(models.Model): name = models.CharField(max_length=100) links = GenericRelation(Link) @@ -113,7 +106,6 @@ class Developer(models.Model): name = models.CharField(max_length=15) -@python_2_unicode_compatible class Team(models.Model): name = models.CharField(max_length=15) members = models.ManyToManyField(Developer) diff --git a/tests/generic_views/models.py b/tests/generic_views/models.py index a840df7d62..8f806b9a85 100644 --- a/tests/generic_views/models.py +++ b/tests/generic_views/models.py @@ -2,10 +2,8 @@ from django.db import models from django.db.models import QuerySet from django.db.models.manager import BaseManager from django.urls import reverse -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Artist(models.Model): name = models.CharField(max_length=100) @@ -21,7 +19,6 @@ class Artist(models.Model): return reverse('artist_detail', kwargs={'pk': self.id}) -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=100) slug = models.SlugField() @@ -41,7 +38,6 @@ class DoesNotExistQuerySet(QuerySet): DoesNotExistBookManager = BaseManager.from_queryset(DoesNotExistQuerySet) -@python_2_unicode_compatible class Book(models.Model): name = models.CharField(max_length=300) slug = models.SlugField() diff --git a/tests/get_object_or_404/models.py b/tests/get_object_or_404/models.py index 4460e46642..ce74bc04ad 100644 --- a/tests/get_object_or_404/models.py +++ b/tests/get_object_or_404/models.py @@ -11,10 +11,8 @@ performing a ``filter()`` lookup and raising a ``Http404`` exception if a """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=50) @@ -27,7 +25,6 @@ class ArticleManager(models.Manager): return super(ArticleManager, self).get_queryset().filter(authors__name__icontains='sir') -@python_2_unicode_compatible class Article(models.Model): authors = models.ManyToManyField(Author) title = models.CharField(max_length=50) diff --git a/tests/get_or_create/models.py b/tests/get_or_create/models.py index 5d6e69de3a..cfde80ce85 100644 --- a/tests/get_or_create/models.py +++ b/tests/get_or_create/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Person(models.Model): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) diff --git a/tests/gis_tests/distapp/models.py b/tests/gis_tests/distapp/models.py index 43a2acacdf..1a5ef2cf90 100644 --- a/tests/gis_tests/distapp/models.py +++ b/tests/gis_tests/distapp/models.py @@ -1,10 +1,8 @@ from django.contrib.gis.db import models -from django.utils.encoding import python_2_unicode_compatible from ..utils import gisfield_may_be_null -@python_2_unicode_compatible class NamedModel(models.Model): name = models.CharField(max_length=30) diff --git a/tests/gis_tests/geo3d/models.py b/tests/gis_tests/geo3d/models.py index 42467c5ce4..b7d3257f99 100644 --- a/tests/gis_tests/geo3d/models.py +++ b/tests/gis_tests/geo3d/models.py @@ -1,8 +1,6 @@ from django.contrib.gis.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class NamedModel(models.Model): name = models.CharField(max_length=30) diff --git a/tests/gis_tests/geoadmin/models.py b/tests/gis_tests/geoadmin/models.py index e57dcd7e9a..9303dc1228 100644 --- a/tests/gis_tests/geoadmin/models.py +++ b/tests/gis_tests/geoadmin/models.py @@ -1,10 +1,8 @@ from django.contrib.gis.db import models -from django.utils.encoding import python_2_unicode_compatible from ..admin import admin -@python_2_unicode_compatible class City(models.Model): name = models.CharField(max_length=30) point = models.PointField() diff --git a/tests/gis_tests/geoapp/models.py b/tests/gis_tests/geoapp/models.py index f5f4c38b42..83e3242043 100644 --- a/tests/gis_tests/geoapp/models.py +++ b/tests/gis_tests/geoapp/models.py @@ -1,10 +1,8 @@ from django.contrib.gis.db import models -from django.utils.encoding import python_2_unicode_compatible from ..utils import gisfield_may_be_null -@python_2_unicode_compatible class NamedModel(models.Model): name = models.CharField(max_length=30) diff --git a/tests/gis_tests/geogapp/models.py b/tests/gis_tests/geogapp/models.py index 6bc5955923..3a658a6c47 100644 --- a/tests/gis_tests/geogapp/models.py +++ b/tests/gis_tests/geogapp/models.py @@ -1,8 +1,6 @@ from django.contrib.gis.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class NamedModel(models.Model): name = models.CharField(max_length=30) diff --git a/tests/gis_tests/layermap/models.py b/tests/gis_tests/layermap/models.py index 25dd0e4bcd..7bb7717fe8 100644 --- a/tests/gis_tests/layermap/models.py +++ b/tests/gis_tests/layermap/models.py @@ -1,8 +1,6 @@ from django.contrib.gis.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class NamedModel(models.Model): name = models.CharField(max_length=25) diff --git a/tests/gis_tests/relatedapp/models.py b/tests/gis_tests/relatedapp/models.py index 6d674588dd..749f39f74c 100644 --- a/tests/gis_tests/relatedapp/models.py +++ b/tests/gis_tests/relatedapp/models.py @@ -1,5 +1,4 @@ from django.contrib.gis.db import models -from django.utils.encoding import python_2_unicode_compatible class SimpleModel(models.Model): @@ -8,7 +7,6 @@ class SimpleModel(models.Model): required_db_features = ['gis_enabled'] -@python_2_unicode_compatible class Location(SimpleModel): point = models.PointField() @@ -16,7 +14,6 @@ class Location(SimpleModel): return self.point.wkt -@python_2_unicode_compatible class City(SimpleModel): name = models.CharField(max_length=50) state = models.CharField(max_length=2) @@ -35,7 +32,6 @@ class DirectoryEntry(SimpleModel): location = models.ForeignKey(AugmentedLocation, models.CASCADE) -@python_2_unicode_compatible class Parcel(SimpleModel): name = models.CharField(max_length=30) city = models.ForeignKey(City, models.CASCADE) diff --git a/tests/inline_formsets/models.py b/tests/inline_formsets/models.py index 42cf810f53..90d434e123 100644 --- a/tests/inline_formsets/models.py +++ b/tests/inline_formsets/models.py @@ -1,5 +1,4 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible class School(models.Model): @@ -17,7 +16,6 @@ class Child(models.Model): name = models.CharField(max_length=100) -@python_2_unicode_compatible class Poet(models.Model): name = models.CharField(max_length=100) @@ -25,7 +23,6 @@ class Poet(models.Model): return self.name -@python_2_unicode_compatible class Poem(models.Model): poet = models.ForeignKey(Poet, models.CASCADE) name = models.CharField(max_length=100) diff --git a/tests/introspection/models.py b/tests/introspection/models.py index 023e622beb..2a1746531d 100644 --- a/tests/introspection/models.py +++ b/tests/introspection/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class City(models.Model): id = models.BigAutoField(primary_key=True) name = models.CharField(max_length=50) @@ -11,7 +9,6 @@ class City(models.Model): return self.name -@python_2_unicode_compatible class District(models.Model): city = models.ForeignKey(City, models.CASCADE, primary_key=True) name = models.CharField(max_length=50) @@ -20,7 +17,6 @@ class District(models.Model): return self.name -@python_2_unicode_compatible class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) @@ -36,7 +32,6 @@ class Reporter(models.Model): return "%s %s" % (self.first_name, self.last_name) -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateField() diff --git a/tests/lookup/models.py b/tests/lookup/models.py index 3490422f69..9cf053d873 100644 --- a/tests/lookup/models.py +++ b/tests/lookup/models.py @@ -6,7 +6,6 @@ This demonstrates features of the database API. from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible class Alarm(models.Model): @@ -24,7 +23,6 @@ class Author(models.Model): ordering = ('name', ) -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateTimeField() @@ -45,7 +43,6 @@ class Tag(models.Model): ordering = ('name', ) -@python_2_unicode_compatible class Season(models.Model): year = models.PositiveSmallIntegerField() gt = models.IntegerField(null=True, blank=True) @@ -54,7 +51,6 @@ class Season(models.Model): return six.text_type(self.year) -@python_2_unicode_compatible class Game(models.Model): season = models.ForeignKey(Season, models.CASCADE, related_name='games') home = models.CharField(max_length=100) @@ -64,7 +60,6 @@ class Game(models.Model): return "%s at %s" % (self.away, self.home) -@python_2_unicode_compatible class Player(models.Model): name = models.CharField(max_length=100) games = models.ManyToManyField(Game, related_name='players') diff --git a/tests/m2m_and_m2o/models.py b/tests/m2m_and_m2o/models.py index 621c56ca1a..7174e6369a 100644 --- a/tests/m2m_and_m2o/models.py +++ b/tests/m2m_and_m2o/models.py @@ -5,14 +5,12 @@ Make sure to set ``related_name`` if you use relationships to the same table. """ from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible class User(models.Model): username = models.CharField(max_length=20) -@python_2_unicode_compatible class Issue(models.Model): num = models.IntegerField() cc = models.ManyToManyField(User, blank=True, related_name='test_issue_cc') diff --git a/tests/m2m_intermediary/models.py b/tests/m2m_intermediary/models.py index dbd822df51..3101fd8a2d 100644 --- a/tests/m2m_intermediary/models.py +++ b/tests/m2m_intermediary/models.py @@ -10,10 +10,8 @@ field, which specifies the ``Reporter``'s position for the given article (e.g. "Staff writer"). """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) @@ -22,7 +20,6 @@ class Reporter(models.Model): return "%s %s" % (self.first_name, self.last_name) -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateField() @@ -31,7 +28,6 @@ class Article(models.Model): return self.headline -@python_2_unicode_compatible class Writer(models.Model): reporter = models.ForeignKey(Reporter, models.CASCADE) article = models.ForeignKey(Article, models.CASCADE) diff --git a/tests/m2m_multiple/models.py b/tests/m2m_multiple/models.py index a6db9425bd..7a77044c2c 100644 --- a/tests/m2m_multiple/models.py +++ b/tests/m2m_multiple/models.py @@ -8,10 +8,8 @@ Set ``related_name`` to designate what the reverse relationship is called. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Category(models.Model): name = models.CharField(max_length=20) @@ -22,7 +20,6 @@ class Category(models.Model): return self.name -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=50) pub_date = models.DateTimeField() diff --git a/tests/m2m_recursive/models.py b/tests/m2m_recursive/models.py index d224b3d572..fd4f4ad166 100644 --- a/tests/m2m_recursive/models.py +++ b/tests/m2m_recursive/models.py @@ -17,10 +17,8 @@ appropriate. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Person(models.Model): name = models.CharField(max_length=20) friends = models.ManyToManyField('self') diff --git a/tests/m2m_regress/models.py b/tests/m2m_regress/models.py index 57f02b8f90..70966bd0b8 100644 --- a/tests/m2m_regress/models.py +++ b/tests/m2m_regress/models.py @@ -1,11 +1,9 @@ from django.contrib.auth import models as auth from django.db import models -from django.utils.encoding import python_2_unicode_compatible # No related name is needed here, since symmetrical relations are not # explicitly reversible. -@python_2_unicode_compatible class SelfRefer(models.Model): name = models.CharField(max_length=10) references = models.ManyToManyField('self') @@ -15,7 +13,6 @@ class SelfRefer(models.Model): return self.name -@python_2_unicode_compatible class Tag(models.Model): name = models.CharField(max_length=10) @@ -24,7 +21,6 @@ class Tag(models.Model): # Regression for #11956 -- a many to many to the base class -@python_2_unicode_compatible class TagCollection(Tag): tags = models.ManyToManyField(Tag, related_name='tag_collections') @@ -34,7 +30,6 @@ class TagCollection(Tag): # A related_name is required on one of the ManyToManyField entries here because # they are both addressable as reverse relations from Tag. -@python_2_unicode_compatible class Entry(models.Model): name = models.CharField(max_length=10) topics = models.ManyToManyField(Tag) @@ -54,7 +49,6 @@ class SelfReferChildSibling(SelfRefer): # Many-to-Many relation between models, where one of the PK's isn't an Autofield -@python_2_unicode_compatible class Line(models.Model): name = models.CharField(max_length=100) diff --git a/tests/m2m_signals/models.py b/tests/m2m_signals/models.py index e4110ccf34..c156128c83 100644 --- a/tests/m2m_signals/models.py +++ b/tests/m2m_signals/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Part(models.Model): name = models.CharField(max_length=20) @@ -13,7 +11,6 @@ class Part(models.Model): return self.name -@python_2_unicode_compatible class Car(models.Model): name = models.CharField(max_length=20) default_parts = models.ManyToManyField(Part) @@ -30,7 +27,6 @@ class SportsCar(Car): price = models.IntegerField() -@python_2_unicode_compatible class Person(models.Model): name = models.CharField(max_length=20) fans = models.ManyToManyField('self', related_name='idols', symmetrical=False) diff --git a/tests/m2m_through/models.py b/tests/m2m_through/models.py index dab3be5164..5f9fba27a7 100644 --- a/tests/m2m_through/models.py +++ b/tests/m2m_through/models.py @@ -1,11 +1,9 @@ from datetime import datetime from django.db import models -from django.utils.encoding import python_2_unicode_compatible # M2M described on one of the models -@python_2_unicode_compatible class Person(models.Model): name = models.CharField(max_length=128) @@ -16,7 +14,6 @@ class Person(models.Model): return self.name -@python_2_unicode_compatible class Group(models.Model): name = models.CharField(max_length=128) members = models.ManyToManyField(Person, through='Membership') @@ -34,7 +31,6 @@ class Group(models.Model): return self.name -@python_2_unicode_compatible class Membership(models.Model): person = models.ForeignKey(Person, models.CASCADE) group = models.ForeignKey(Group, models.CASCADE) @@ -48,7 +44,6 @@ class Membership(models.Model): return "%s is a member of %s" % (self.person.name, self.group.name) -@python_2_unicode_compatible class CustomMembership(models.Model): person = models.ForeignKey( Person, @@ -74,7 +69,6 @@ class TestNoDefaultsOrNulls(models.Model): nodefaultnonull = models.CharField(max_length=5) -@python_2_unicode_compatible class PersonSelfRefM2M(models.Model): name = models.CharField(max_length=5) friends = models.ManyToManyField('self', through="Friendship", symmetrical=False) @@ -90,7 +84,6 @@ class Friendship(models.Model): # Custom through link fields -@python_2_unicode_compatible class Event(models.Model): title = models.CharField(max_length=50) invitees = models.ManyToManyField( @@ -110,7 +103,6 @@ class Invitation(models.Model): invitee = models.ForeignKey(Person, models.CASCADE, related_name='invitations') -@python_2_unicode_compatible class Employee(models.Model): name = models.CharField(max_length=5) subordinates = models.ManyToManyField( diff --git a/tests/m2m_through_regress/models.py b/tests/m2m_through_regress/models.py index 9f0f44cd21..1214c93ea1 100644 --- a/tests/m2m_through_regress/models.py +++ b/tests/m2m_through_regress/models.py @@ -1,10 +1,8 @@ from django.contrib.auth.models import User from django.db import models -from django.utils.encoding import python_2_unicode_compatible # Forward declared intermediate model -@python_2_unicode_compatible class Membership(models.Model): person = models.ForeignKey('Person', models.CASCADE) group = models.ForeignKey('Group', models.CASCADE) @@ -15,7 +13,6 @@ class Membership(models.Model): # using custom id column to test ticket #11107 -@python_2_unicode_compatible class UserMembership(models.Model): id = models.AutoField(db_column='usermembership_id', primary_key=True) user = models.ForeignKey(User, models.CASCADE) @@ -26,7 +23,6 @@ class UserMembership(models.Model): return "%s is a user and member of %s" % (self.user.username, self.group.name) -@python_2_unicode_compatible class Person(models.Model): name = models.CharField(max_length=128) @@ -34,7 +30,6 @@ class Person(models.Model): return self.name -@python_2_unicode_compatible class Group(models.Model): name = models.CharField(max_length=128) # Membership object defined as a class @@ -65,7 +60,6 @@ class B(models.Model): # Using to_field on the through model -@python_2_unicode_compatible class Car(models.Model): make = models.CharField(max_length=20, unique=True, null=True) drivers = models.ManyToManyField('Driver', through='CarDriver') @@ -74,7 +68,6 @@ class Car(models.Model): return "%s" % self.make -@python_2_unicode_compatible class Driver(models.Model): name = models.CharField(max_length=20, unique=True, null=True) @@ -85,7 +78,6 @@ class Driver(models.Model): ordering = ('name',) -@python_2_unicode_compatible class CarDriver(models.Model): car = models.ForeignKey('Car', models.CASCADE, to_field='make') driver = models.ForeignKey('Driver', models.CASCADE, to_field='name') diff --git a/tests/m2o_recursive/models.py b/tests/m2o_recursive/models.py index d62c514a25..bb73589800 100644 --- a/tests/m2o_recursive/models.py +++ b/tests/m2o_recursive/models.py @@ -11,10 +11,8 @@ Set ``related_name`` to designate what the reverse relationship is called. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Category(models.Model): name = models.CharField(max_length=20) parent = models.ForeignKey('self', models.SET_NULL, blank=True, null=True, related_name='child_set') @@ -23,7 +21,6 @@ class Category(models.Model): return self.name -@python_2_unicode_compatible class Person(models.Model): full_name = models.CharField(max_length=20) mother = models.ForeignKey('self', models.SET_NULL, null=True, related_name='mothers_child_set') diff --git a/tests/managers_regress/models.py b/tests/managers_regress/models.py index b39e69b9ad..f5fd648bff 100644 --- a/tests/managers_regress/models.py +++ b/tests/managers_regress/models.py @@ -7,7 +7,7 @@ from django.contrib.contenttypes.fields import ( ) from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.encoding import force_text class OnlyFred(models.Manager): @@ -55,7 +55,6 @@ class AbstractBase3(models.Model): abstract = True -@python_2_unicode_compatible class Parent(models.Model): name = models.CharField(max_length=50) @@ -68,7 +67,6 @@ class Parent(models.Model): # Managers from base classes are inherited and, if no manager is specified # *and* the parent has a manager specified, the first one (in the MRO) will # become the default. -@python_2_unicode_compatible class Child1(AbstractBase1): data = models.CharField(max_length=25) @@ -76,7 +74,6 @@ class Child1(AbstractBase1): return self.data -@python_2_unicode_compatible class Child2(AbstractBase1, AbstractBase2): data = models.CharField(max_length=25) @@ -84,7 +81,6 @@ class Child2(AbstractBase1, AbstractBase2): return self.data -@python_2_unicode_compatible class Child3(AbstractBase1, AbstractBase3): data = models.CharField(max_length=25) @@ -92,7 +88,6 @@ class Child3(AbstractBase1, AbstractBase3): return self.data -@python_2_unicode_compatible class Child4(AbstractBase1): data = models.CharField(max_length=25) @@ -104,7 +99,6 @@ class Child4(AbstractBase1): return self.data -@python_2_unicode_compatible class Child5(AbstractBase3): name = models.CharField(max_length=25) @@ -124,7 +118,6 @@ class Child7(Parent): # RelatedManagers -@python_2_unicode_compatible class RelatedModel(models.Model): test_gfk = GenericRelation('RelationModel', content_type_field='gfk_ctype', object_id_field='gfk_id') exact = models.NullBooleanField() @@ -133,7 +126,6 @@ class RelatedModel(models.Model): return force_text(self.pk) -@python_2_unicode_compatible class RelationModel(models.Model): fk = models.ForeignKey(RelatedModel, models.CASCADE, related_name='test_fk') diff --git a/tests/many_to_many/models.py b/tests/many_to_many/models.py index b0e708ebb4..cf3add7848 100644 --- a/tests/many_to_many/models.py +++ b/tests/many_to_many/models.py @@ -7,10 +7,8 @@ In this example, an ``Article`` can be published in multiple ``Publication`` objects, and a ``Publication`` has multiple ``Article`` objects. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Publication(models.Model): title = models.CharField(max_length=30) @@ -21,7 +19,6 @@ class Publication(models.Model): ordering = ('title',) -@python_2_unicode_compatible class Tag(models.Model): id = models.BigAutoField(primary_key=True) name = models.CharField(max_length=50) @@ -30,7 +27,6 @@ class Tag(models.Model): return self.name -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) # Assign a unicode string as name to make sure the intermediary model is diff --git a/tests/many_to_one/models.py b/tests/many_to_one/models.py index 09578b56a3..93b8029b2f 100644 --- a/tests/many_to_one/models.py +++ b/tests/many_to_one/models.py @@ -4,10 +4,8 @@ Many-to-one relationships To define a many-to-one relationship, use ``ForeignKey()``. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) @@ -17,7 +15,6 @@ class Reporter(models.Model): return "%s %s" % (self.first_name, self.last_name) -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateField() @@ -30,7 +27,6 @@ class Article(models.Model): ordering = ('headline',) -@python_2_unicode_compatible class City(models.Model): id = models.BigAutoField(primary_key=True) name = models.CharField(max_length=50) @@ -39,7 +35,6 @@ class City(models.Model): return self.name -@python_2_unicode_compatible class District(models.Model): city = models.ForeignKey(City, models.CASCADE, related_name='districts', null=True) name = models.CharField(max_length=50) @@ -80,7 +75,6 @@ class ToFieldChild(models.Model): # Multiple paths to the same model (#7110, #7125) -@python_2_unicode_compatible class Category(models.Model): name = models.CharField(max_length=20) @@ -92,7 +86,6 @@ class Record(models.Model): category = models.ForeignKey(Category, models.CASCADE) -@python_2_unicode_compatible class Relation(models.Model): left = models.ForeignKey(Record, models.CASCADE, related_name='left_set') right = models.ForeignKey(Record, models.CASCADE, related_name='right_set') diff --git a/tests/many_to_one_null/models.py b/tests/many_to_one_null/models.py index 2a67623dc3..23b4294593 100644 --- a/tests/many_to_one_null/models.py +++ b/tests/many_to_one_null/models.py @@ -6,10 +6,8 @@ To define a many-to-one relationship that can have a null foreign key, use """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Reporter(models.Model): name = models.CharField(max_length=30) @@ -17,7 +15,6 @@ class Reporter(models.Model): return self.name -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) reporter = models.ForeignKey(Reporter, models.SET_NULL, null=True) diff --git a/tests/migrations/models.py b/tests/migrations/models.py index b1a10210b6..dea320c033 100644 --- a/tests/migrations/models.py +++ b/tests/migrations/models.py @@ -1,7 +1,6 @@ from django.apps.registry import Apps from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible class CustomModelBase(models.base.ModelBase): @@ -12,7 +11,6 @@ class ModelWithCustomBase(six.with_metaclass(CustomModelBase, models.Model)): pass -@python_2_unicode_compatible class UnicodeModel(models.Model): title = models.CharField('ÚÑÍ¢ÓÐÉ', max_length=20, default='“Ðjáñgó”') diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py index da91fc88b7..333a6050ab 100644 --- a/tests/model_forms/models.py +++ b/tests/model_forms/models.py @@ -17,7 +17,6 @@ from django.core.files.storage import FileSystemStorage from django.db import models from django.utils import six from django.utils._os import upath -from django.utils.encoding import python_2_unicode_compatible from django.utils.six.moves import range temp_storage_dir = tempfile.mkdtemp() @@ -40,7 +39,6 @@ class Person(models.Model): name = models.CharField(max_length=100) -@python_2_unicode_compatible class Category(models.Model): name = models.CharField(max_length=20) slug = models.SlugField(max_length=20) @@ -53,7 +51,6 @@ class Category(models.Model): return self.__str__() -@python_2_unicode_compatible class Writer(models.Model): name = models.CharField(max_length=50, help_text='Use both first and last names.') @@ -64,7 +61,6 @@ class Writer(models.Model): return self.name -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=50) slug = models.SlugField() @@ -96,7 +92,6 @@ class BetterWriter(Writer): score = models.IntegerField() -@python_2_unicode_compatible class Publication(models.Model): title = models.CharField(max_length=30) date_published = models.DateField() @@ -135,7 +130,6 @@ class Author1(models.Model): full_name = models.CharField(max_length=255) -@python_2_unicode_compatible class WriterProfile(models.Model): writer = models.OneToOneField(Writer, models.CASCADE, primary_key=True) age = models.PositiveIntegerField() @@ -148,7 +142,6 @@ class Document(models.Model): myfile = models.FileField(upload_to='unused', blank=True) -@python_2_unicode_compatible class TextFile(models.Model): description = models.CharField(max_length=20) file = models.FileField(storage=temp_storage, upload_to='tests', max_length=15) @@ -177,7 +170,6 @@ try: test_images = True - @python_2_unicode_compatible class ImageFile(models.Model): def custom_upload_path(self, filename): path = self.path or 'tests' @@ -196,7 +188,6 @@ try: def __str__(self): return self.description - @python_2_unicode_compatible class OptionalImageFile(models.Model): def custom_upload_path(self, filename): path = self.path or 'tests' @@ -220,7 +211,6 @@ class Homepage(models.Model): url = models.URLField() -@python_2_unicode_compatible class Product(models.Model): slug = models.SlugField(unique=True) @@ -228,7 +218,6 @@ class Product(models.Model): return self.slug -@python_2_unicode_compatible class Price(models.Model): price = models.DecimalField(max_digits=10, decimal_places=2) quantity = models.PositiveIntegerField() @@ -253,7 +242,6 @@ class ArticleStatus(models.Model): status = models.CharField(max_length=2, choices=ARTICLE_STATUS_CHAR, blank=True, null=True) -@python_2_unicode_compatible class Inventory(models.Model): barcode = models.PositiveIntegerField(unique=True) parent = models.ForeignKey('self', models.SET_NULL, to_field='barcode', blank=True, null=True) @@ -292,7 +280,6 @@ class DerivedBook(Book, BookXtra): pass -@python_2_unicode_compatible class ExplicitPK(models.Model): key = models.CharField(max_length=20, primary_key=True) desc = models.CharField(max_length=20, blank=True, unique=True) @@ -304,7 +291,6 @@ class ExplicitPK(models.Model): return self.key -@python_2_unicode_compatible class Post(models.Model): title = models.CharField(max_length=50, unique_for_date='posted', blank=True) slug = models.CharField(max_length=50, unique_for_year='posted', blank=True) @@ -315,7 +301,6 @@ class Post(models.Model): return self.title -@python_2_unicode_compatible class DateTimePost(models.Model): title = models.CharField(max_length=50, unique_for_date='posted', blank=True) slug = models.CharField(max_length=50, unique_for_year='posted', blank=True) @@ -330,7 +315,6 @@ class DerivedPost(Post): pass -@python_2_unicode_compatible class BigInt(models.Model): biggie = models.BigIntegerField() @@ -363,7 +347,6 @@ class FlexibleDatePost(models.Model): posted = models.DateField(blank=True, null=True) -@python_2_unicode_compatible class Colour(models.Model): name = models.CharField(max_length=50) diff --git a/tests/model_formsets/models.py b/tests/model_formsets/models.py index 421d873704..b7b1f1edb9 100644 --- a/tests/model_formsets/models.py +++ b/tests/model_formsets/models.py @@ -3,10 +3,8 @@ import uuid from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=100) @@ -21,7 +19,6 @@ class BetterAuthor(Author): write_speed = models.IntegerField() -@python_2_unicode_compatible class Book(models.Model): author = models.ForeignKey(Author, models.CASCADE) title = models.CharField(max_length=100) @@ -40,7 +37,6 @@ class Book(models.Model): assert self.author.name is not None -@python_2_unicode_compatible class BookWithCustomPK(models.Model): my_pk = models.DecimalField(max_digits=5, decimal_places=0, primary_key=True) author = models.ForeignKey(Author, models.CASCADE) @@ -54,7 +50,6 @@ class Editor(models.Model): name = models.CharField(max_length=100) -@python_2_unicode_compatible class BookWithOptionalAltEditor(models.Model): author = models.ForeignKey(Author, models.CASCADE) # Optional secondary author @@ -70,7 +65,6 @@ class BookWithOptionalAltEditor(models.Model): return self.title -@python_2_unicode_compatible class AlternateBook(Book): notes = models.CharField(max_length=100) @@ -78,7 +72,6 @@ class AlternateBook(Book): return '%s - %s' % (self.title, self.notes) -@python_2_unicode_compatible class AuthorMeeting(models.Model): name = models.CharField(max_length=100) authors = models.ManyToManyField(Author) @@ -96,7 +89,6 @@ class CustomPrimaryKey(models.Model): # models for inheritance tests. -@python_2_unicode_compatible class Place(models.Model): name = models.CharField(max_length=50) city = models.CharField(max_length=50) @@ -105,7 +97,6 @@ class Place(models.Model): return self.name -@python_2_unicode_compatible class Owner(models.Model): auto_id = models.AutoField(primary_key=True) name = models.CharField(max_length=100) @@ -122,7 +113,6 @@ class Location(models.Model): lon = models.CharField(max_length=100) -@python_2_unicode_compatible class OwnerProfile(models.Model): owner = models.OneToOneField(Owner, models.CASCADE, primary_key=True) age = models.PositiveIntegerField() @@ -131,7 +121,6 @@ class OwnerProfile(models.Model): return "%s is %d" % (self.owner.name, self.age) -@python_2_unicode_compatible class Restaurant(Place): serves_pizza = models.BooleanField(default=False) @@ -139,7 +128,6 @@ class Restaurant(Place): return self.name -@python_2_unicode_compatible class Product(models.Model): slug = models.SlugField(unique=True) @@ -147,7 +135,6 @@ class Product(models.Model): return self.slug -@python_2_unicode_compatible class Price(models.Model): price = models.DecimalField(max_digits=10, decimal_places=2) quantity = models.PositiveIntegerField() @@ -170,7 +157,6 @@ class ClassyMexicanRestaurant(MexicanRestaurant): # models for testing unique_together validation when a fk is involved and # using inlineformset_factory. -@python_2_unicode_compatible class Repository(models.Model): name = models.CharField(max_length=25) @@ -178,7 +164,6 @@ class Repository(models.Model): return self.name -@python_2_unicode_compatible class Revision(models.Model): repository = models.ForeignKey(Repository, models.CASCADE) revision = models.CharField(max_length=40) @@ -208,7 +193,6 @@ class Team(models.Model): name = models.CharField(max_length=100) -@python_2_unicode_compatible class Player(models.Model): team = models.ForeignKey(Team, models.SET_NULL, null=True) name = models.CharField(max_length=100) @@ -218,7 +202,6 @@ class Player(models.Model): # Models for testing custom ModelForm save methods in formsets and inline formsets -@python_2_unicode_compatible class Poet(models.Model): name = models.CharField(max_length=100) @@ -226,7 +209,6 @@ class Poet(models.Model): return self.name -@python_2_unicode_compatible class Poem(models.Model): poet = models.ForeignKey(Poet, models.CASCADE) name = models.CharField(max_length=100) @@ -235,7 +217,6 @@ class Poem(models.Model): return self.name -@python_2_unicode_compatible class Post(models.Model): title = models.CharField(max_length=50, unique_for_date='posted', blank=True) slug = models.CharField(max_length=50, unique_for_year='posted', blank=True) diff --git a/tests/model_formsets_regress/models.py b/tests/model_formsets_regress/models.py index 064cddd4a0..29d1194bc2 100644 --- a/tests/model_formsets_regress/models.py +++ b/tests/model_formsets_regress/models.py @@ -1,5 +1,4 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible class User(models.Model): @@ -40,7 +39,6 @@ class Network(models.Model): name = models.CharField(max_length=15) -@python_2_unicode_compatible class Host(models.Model): network = models.ForeignKey(Network, models.CASCADE) hostname = models.CharField(max_length=25) diff --git a/tests/model_inheritance/models.py b/tests/model_inheritance/models.py index 4c7d4a7c8a..44bf752d00 100644 --- a/tests/model_inheritance/models.py +++ b/tests/model_inheritance/models.py @@ -12,7 +12,6 @@ Model inheritance exists in two varieties: Both styles are demonstrated here. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible # @@ -20,7 +19,6 @@ from django.utils.encoding import python_2_unicode_compatible # -@python_2_unicode_compatible class CommonInfo(models.Model): name = models.CharField(max_length=50) age = models.PositiveIntegerField() @@ -52,7 +50,6 @@ class Post(models.Model): title = models.CharField(max_length=50) -@python_2_unicode_compatible class Attachment(models.Model): post = models.ForeignKey( Post, @@ -81,7 +78,6 @@ class Link(Attachment): # Multi-table inheritance # -@python_2_unicode_compatible class Chef(models.Model): name = models.CharField(max_length=50) @@ -89,7 +85,6 @@ class Chef(models.Model): return "%s the chef" % self.name -@python_2_unicode_compatible class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) @@ -106,7 +101,6 @@ class Rating(models.Model): ordering = ['-rating'] -@python_2_unicode_compatible class Restaurant(Place, Rating): serves_hot_dogs = models.BooleanField(default=False) serves_pizza = models.BooleanField(default=False) @@ -119,7 +113,6 @@ class Restaurant(Place, Rating): return "%s the restaurant" % self.name -@python_2_unicode_compatible class ItalianRestaurant(Restaurant): serves_gnocchi = models.BooleanField(default=False) @@ -127,7 +120,6 @@ class ItalianRestaurant(Restaurant): return "%s the italian restaurant" % self.name -@python_2_unicode_compatible class Supplier(Place): customers = models.ManyToManyField(Restaurant, related_name='provider') @@ -135,7 +127,6 @@ class Supplier(Place): return "%s the supplier" % self.name -@python_2_unicode_compatible class ParkingLot(Place): # An explicit link to the parent (we can control the attribute name). parent = models.OneToOneField(Place, models.CASCADE, primary_key=True, parent_link=True) diff --git a/tests/model_inheritance_regress/models.py b/tests/model_inheritance_regress/models.py index 69ce0d9e2b..358217554b 100644 --- a/tests/model_inheritance_regress/models.py +++ b/tests/model_inheritance_regress/models.py @@ -1,10 +1,8 @@ import datetime from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) @@ -16,7 +14,6 @@ class Place(models.Model): return "%s the place" % self.name -@python_2_unicode_compatible class Restaurant(Place): serves_hot_dogs = models.BooleanField(default=False) serves_pizza = models.BooleanField(default=False) @@ -25,7 +22,6 @@ class Restaurant(Place): return "%s the restaurant" % self.name -@python_2_unicode_compatible class ItalianRestaurant(Restaurant): serves_gnocchi = models.BooleanField(default=False) @@ -33,7 +29,6 @@ class ItalianRestaurant(Restaurant): return "%s the italian restaurant" % self.name -@python_2_unicode_compatible class ParkingLot(Place): # An explicit link to the parent (we can control the attribute name). parent = models.OneToOneField(Place, models.CASCADE, primary_key=True, parent_link=True) @@ -65,7 +60,6 @@ class ParkingLot4B(Place, ParkingLot4): pass -@python_2_unicode_compatible class Supplier(models.Model): name = models.CharField(max_length=50) restaurant = models.ForeignKey(Restaurant, models.CASCADE) @@ -95,7 +89,6 @@ class SelfRefChild(SelfRefParent): child_data = models.IntegerField() -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateTimeField() @@ -130,7 +123,6 @@ class QualityControl(Evaluation): assignee = models.CharField(max_length=50) -@python_2_unicode_compatible class BaseM(models.Model): base_name = models.CharField(max_length=100) @@ -138,7 +130,6 @@ class BaseM(models.Model): return self.base_name -@python_2_unicode_compatible class DerivedM(BaseM): customPK = models.IntegerField(primary_key=True) derived_name = models.CharField(max_length=100) @@ -166,7 +157,6 @@ class InternalCertificationAudit(CertificationAudit): # Abstract classes don't get m2m tables autocreated. -@python_2_unicode_compatible class Person(models.Model): name = models.CharField(max_length=100) @@ -177,7 +167,6 @@ class Person(models.Model): return self.name -@python_2_unicode_compatible class AbstractEvent(models.Model): name = models.CharField(max_length=100) attendees = models.ManyToManyField(Person, related_name="%(class)s_set") diff --git a/tests/model_regress/models.py b/tests/model_regress/models.py index 147116d7e2..3208db90b8 100644 --- a/tests/model_regress/models.py +++ b/tests/model_regress/models.py @@ -1,5 +1,4 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible CHOICES = ( (1, 'first'), @@ -7,7 +6,6 @@ CHOICES = ( ) -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100, default='Default headline') pub_date = models.DateTimeField() @@ -38,7 +36,6 @@ class Event(models.Model): when = models.DateTimeField() -@python_2_unicode_compatible class Department(models.Model): id = models.PositiveIntegerField(primary_key=True) name = models.CharField(max_length=200) @@ -47,7 +44,6 @@ class Department(models.Model): return self.name -@python_2_unicode_compatible class Worker(models.Model): department = models.ForeignKey(Department, models.CASCADE) name = models.CharField(max_length=200) @@ -56,7 +52,6 @@ class Worker(models.Model): return self.name -@python_2_unicode_compatible class BrokenUnicodeMethod(models.Model): name = models.CharField(max_length=7) diff --git a/tests/modeladmin/models.py b/tests/modeladmin/models.py index 64cc86aa66..861a2dbb9d 100644 --- a/tests/modeladmin/models.py +++ b/tests/modeladmin/models.py @@ -1,9 +1,7 @@ from django.contrib.auth.models import User from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Band(models.Model): name = models.CharField(max_length=100) bio = models.TextField() diff --git a/tests/multiple_database/models.py b/tests/multiple_database/models.py index 367cd31d63..55247f6e18 100644 --- a/tests/multiple_database/models.py +++ b/tests/multiple_database/models.py @@ -4,10 +4,8 @@ from django.contrib.contenttypes.fields import ( ) from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Review(models.Model): source = models.CharField(max_length=100) content_type = models.ForeignKey(ContentType, models.CASCADE) @@ -26,7 +24,6 @@ class PersonManager(models.Manager): return self.get(name=name) -@python_2_unicode_compatible class Person(models.Model): objects = PersonManager() name = models.CharField(max_length=100) @@ -52,7 +49,6 @@ class BookManager(models.Manager): return super(BookManager, self).get_or_create(*args, **kwargs) -@python_2_unicode_compatible class Book(models.Model): objects = BookManager() title = models.CharField(max_length=100) @@ -69,7 +65,6 @@ class Book(models.Model): ordering = ('title',) -@python_2_unicode_compatible class Pet(models.Model): name = models.CharField(max_length=100) owner = models.ForeignKey(Person, models.CASCADE) diff --git a/tests/null_fk/models.py b/tests/null_fk/models.py index 6a7da8f620..5ebce93a65 100644 --- a/tests/null_fk/models.py +++ b/tests/null_fk/models.py @@ -3,7 +3,6 @@ Regression tests for proper working of ForeignKey(null=True). """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible class SystemDetails(models.Model): @@ -20,7 +19,6 @@ class Forum(models.Model): forum_name = models.CharField(max_length=32) -@python_2_unicode_compatible class Post(models.Model): forum = models.ForeignKey(Forum, models.SET_NULL, null=True) title = models.CharField(max_length=32) @@ -29,7 +27,6 @@ class Post(models.Model): return self.title -@python_2_unicode_compatible class Comment(models.Model): post = models.ForeignKey(Post, models.SET_NULL, null=True) comment_text = models.CharField(max_length=250) diff --git a/tests/null_fk_ordering/models.py b/tests/null_fk_ordering/models.py index e65c227f88..a7938cec54 100644 --- a/tests/null_fk_ordering/models.py +++ b/tests/null_fk_ordering/models.py @@ -6,7 +6,6 @@ unexpected results """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible # The first two models represent a very simple null FK ordering case. @@ -14,7 +13,6 @@ class Author(models.Model): name = models.CharField(max_length=150) -@python_2_unicode_compatible class Article(models.Model): title = models.CharField(max_length=150) author = models.ForeignKey(Author, models.SET_NULL, null=True) @@ -36,7 +34,6 @@ class Forum(models.Model): forum_name = models.CharField(max_length=32) -@python_2_unicode_compatible class Post(models.Model): forum = models.ForeignKey(Forum, models.SET_NULL, null=True) title = models.CharField(max_length=32) @@ -45,7 +42,6 @@ class Post(models.Model): return self.title -@python_2_unicode_compatible class Comment(models.Model): post = models.ForeignKey(Post, models.SET_NULL, null=True) comment_text = models.CharField(max_length=250) diff --git a/tests/null_queries/models.py b/tests/null_queries/models.py index b40f4539b3..f2d4caa745 100644 --- a/tests/null_queries/models.py +++ b/tests/null_queries/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Poll(models.Model): question = models.CharField(max_length=200) @@ -10,7 +8,6 @@ class Poll(models.Model): return "Q: %s " % self.question -@python_2_unicode_compatible class Choice(models.Model): poll = models.ForeignKey(Poll, models.CASCADE) choice = models.CharField(max_length=200) diff --git a/tests/one_to_one/models.py b/tests/one_to_one/models.py index c58114dce8..263633347d 100644 --- a/tests/one_to_one/models.py +++ b/tests/one_to_one/models.py @@ -6,10 +6,8 @@ To define a one-to-one relationship, use ``OneToOneField()``. In this example, a ``Place`` optionally can be a ``Restaurant``. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) @@ -18,7 +16,6 @@ class Place(models.Model): return "%s the place" % self.name -@python_2_unicode_compatible class Restaurant(models.Model): place = models.OneToOneField(Place, models.CASCADE, primary_key=True) serves_hot_dogs = models.BooleanField(default=False) @@ -28,7 +25,6 @@ class Restaurant(models.Model): return "%s the restaurant" % self.place.name -@python_2_unicode_compatible class Bar(models.Model): place = models.OneToOneField(Place, models.CASCADE) serves_cocktails = models.BooleanField(default=True) @@ -42,7 +38,6 @@ class UndergroundBar(models.Model): serves_cocktails = models.BooleanField(default=True) -@python_2_unicode_compatible class Waiter(models.Model): restaurant = models.ForeignKey(Restaurant, models.CASCADE) name = models.CharField(max_length=50) @@ -51,7 +46,6 @@ class Waiter(models.Model): return "%s the waiter at %s" % (self.name, self.restaurant) -@python_2_unicode_compatible class Favorites(models.Model): name = models.CharField(max_length=50) restaurants = models.ManyToManyField(Restaurant) @@ -70,7 +64,6 @@ class RelatedModel(models.Model): name = models.CharField(max_length=50) -@python_2_unicode_compatible class MultiModel(models.Model): link1 = models.OneToOneField(Place, models.CASCADE) link2 = models.OneToOneField(ManualPrimaryKey, models.CASCADE) diff --git a/tests/or_lookups/models.py b/tests/or_lookups/models.py index 7dea8cd49e..efe70ab8dd 100644 --- a/tests/or_lookups/models.py +++ b/tests/or_lookups/models.py @@ -10,10 +10,8 @@ clauses using the variable ``django.db.models.Q`` (or any object with an """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=50) pub_date = models.DateTimeField() diff --git a/tests/order_with_respect_to/models.py b/tests/order_with_respect_to/models.py index 17c09dfeae..8f50b42252 100644 --- a/tests/order_with_respect_to/models.py +++ b/tests/order_with_respect_to/models.py @@ -4,14 +4,12 @@ Tests for the order_with_respect_to Meta attribute. from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible class Question(models.Model): text = models.CharField(max_length=200) -@python_2_unicode_compatible class Answer(models.Model): text = models.CharField(max_length=200) question = models.ForeignKey(Question, models.CASCADE) @@ -23,7 +21,6 @@ class Answer(models.Model): return six.text_type(self.text) -@python_2_unicode_compatible class Post(models.Model): title = models.CharField(max_length=200) parent = models.ForeignKey("self", models.SET_NULL, related_name="children", null=True) diff --git a/tests/ordering/models.py b/tests/ordering/models.py index 1f794ca3a1..d3024f5fc0 100644 --- a/tests/ordering/models.py +++ b/tests/ordering/models.py @@ -14,7 +14,6 @@ undefined -- not random, just undefined. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible class Author(models.Model): @@ -24,7 +23,6 @@ class Author(models.Model): ordering = ('-pk',) -@python_2_unicode_compatible class Article(models.Model): author = models.ForeignKey(Author, models.SET_NULL, null=True) second_author = models.ForeignKey(Author, models.SET_NULL, null=True, related_name='+') diff --git a/tests/pagination/models.py b/tests/pagination/models.py index 9dc8d4b776..d84dd42ee6 100644 --- a/tests/pagination/models.py +++ b/tests/pagination/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Article(models.Model): headline = models.CharField(max_length=100, default='Default headline') pub_date = models.DateTimeField() diff --git a/tests/prefetch_related/models.py b/tests/prefetch_related/models.py index 064ce1dfbd..c995acb684 100644 --- a/tests/prefetch_related/models.py +++ b/tests/prefetch_related/models.py @@ -5,13 +5,11 @@ from django.contrib.contenttypes.fields import ( ) from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.functional import cached_property # Basic tests -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=50, unique=True) first_book = models.ForeignKey('Book', models.CASCADE, related_name='first_time_authors') @@ -38,7 +36,6 @@ class FavoriteAuthors(models.Model): ordering = ['id'] -@python_2_unicode_compatible class AuthorAddress(models.Model): author = models.ForeignKey(Author, models.CASCADE, to_field='name', related_name='addresses') address = models.TextField() @@ -50,7 +47,6 @@ class AuthorAddress(models.Model): return self.address -@python_2_unicode_compatible class Book(models.Model): title = models.CharField(max_length=255) authors = models.ManyToManyField(Author, related_name='books') @@ -74,7 +70,6 @@ class Bio(models.Model): books = models.ManyToManyField(Book, blank=True) -@python_2_unicode_compatible class Reader(models.Model): name = models.CharField(max_length=50) books_read = models.ManyToManyField(Book, related_name='read_by') @@ -105,7 +100,6 @@ class TeacherManager(models.Manager): return super(TeacherManager, self).get_queryset().prefetch_related('qualifications') -@python_2_unicode_compatible class Teacher(models.Model): name = models.CharField(max_length=50) qualifications = models.ManyToManyField(Qualification) @@ -129,7 +123,6 @@ class Department(models.Model): # GenericRelation/GenericForeignKey tests -@python_2_unicode_compatible class TaggedItem(models.Model): tag = models.SlugField() content_type = models.ForeignKey( @@ -230,7 +223,6 @@ class Person(models.Model): # Models for nullable FK tests -@python_2_unicode_compatible class Employee(models.Model): name = models.CharField(max_length=50) boss = models.ForeignKey('self', models.SET_NULL, null=True, related_name='serfs') @@ -244,7 +236,6 @@ class Employee(models.Model): # Ticket #19607 -@python_2_unicode_compatible class LessonEntry(models.Model): name1 = models.CharField(max_length=200) name2 = models.CharField(max_length=200) @@ -253,7 +244,6 @@ class LessonEntry(models.Model): return "%s %s" % (self.name1, self.name2) -@python_2_unicode_compatible class WordEntry(models.Model): lesson_entry = models.ForeignKey(LessonEntry, models.CASCADE) name = models.CharField(max_length=200) @@ -264,7 +254,6 @@ class WordEntry(models.Model): # Ticket #21410: Regression when related_name="+" -@python_2_unicode_compatible class Author2(models.Model): name = models.CharField(max_length=50, unique=True) first_book = models.ForeignKey('Book', models.CASCADE, related_name='first_time_authors+') diff --git a/tests/proxy_models/models.py b/tests/proxy_models/models.py index 6960042d78..93430d615f 100644 --- a/tests/proxy_models/models.py +++ b/tests/proxy_models/models.py @@ -5,7 +5,6 @@ than using a new table of their own. This allows them to act as simple proxies, providing a modified interface to the data from the base class. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible # A couple of managers for testing managing overriding in proxy model cases. @@ -21,7 +20,6 @@ class SubManager(models.Manager): return super(SubManager, self).get_queryset().exclude(name="wilma") -@python_2_unicode_compatible class Person(models.Model): """ A simple concrete base class. @@ -101,7 +99,6 @@ class LowerStatusPerson(MyPersonProxy): objects = models.Manager() -@python_2_unicode_compatible class User(models.Model): name = models.CharField(max_length=100) @@ -135,7 +132,6 @@ class Country(models.Model): name = models.CharField(max_length=50) -@python_2_unicode_compatible class State(models.Model): name = models.CharField(max_length=50) country = models.ForeignKey(Country, models.CASCADE) @@ -152,7 +148,6 @@ class StateProxy(State): # and select_related, even when mixed with model inheritance -@python_2_unicode_compatible class BaseUser(models.Model): name = models.CharField(max_length=255) @@ -169,7 +164,6 @@ class ProxyTrackerUser(TrackerUser): proxy = True -@python_2_unicode_compatible class Issue(models.Model): summary = models.CharField(max_length=255) assignee = models.ForeignKey(ProxyTrackerUser, models.CASCADE, related_name='issues') diff --git a/tests/queries/models.py b/tests/queries/models.py index 8c1ba59b67..4d5ed14ff0 100644 --- a/tests/queries/models.py +++ b/tests/queries/models.py @@ -5,7 +5,6 @@ import threading from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible class DumbCategory(models.Model): @@ -17,7 +16,6 @@ class ProxyCategory(DumbCategory): proxy = True -@python_2_unicode_compatible class NamedCategory(DumbCategory): name = models.CharField(max_length=10) @@ -25,7 +23,6 @@ class NamedCategory(DumbCategory): return self.name -@python_2_unicode_compatible class Tag(models.Model): name = models.CharField(max_length=10) parent = models.ForeignKey( @@ -43,7 +40,6 @@ class Tag(models.Model): return self.name -@python_2_unicode_compatible class Note(models.Model): note = models.CharField(max_length=100) misc = models.CharField(max_length=10) @@ -63,7 +59,6 @@ class Note(models.Model): self.lock = threading.Lock() -@python_2_unicode_compatible class Annotation(models.Model): name = models.CharField(max_length=10) tag = models.ForeignKey(Tag, models.CASCADE) @@ -73,7 +68,6 @@ class Annotation(models.Model): return self.name -@python_2_unicode_compatible class ExtraInfo(models.Model): info = models.CharField(max_length=100) note = models.ForeignKey(Note, models.CASCADE) @@ -86,7 +80,6 @@ class ExtraInfo(models.Model): return self.info -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=10) num = models.IntegerField(unique=True) @@ -99,7 +92,6 @@ class Author(models.Model): return self.name -@python_2_unicode_compatible class Item(models.Model): name = models.CharField(max_length=10) created = models.DateTimeField() @@ -115,7 +107,6 @@ class Item(models.Model): return self.name -@python_2_unicode_compatible class Report(models.Model): name = models.CharField(max_length=10) creator = models.ForeignKey(Author, models.SET_NULL, to_field='num', null=True) @@ -124,7 +115,6 @@ class Report(models.Model): return self.name -@python_2_unicode_compatible class Ranking(models.Model): rank = models.IntegerField() author = models.ForeignKey(Author, models.CASCADE) @@ -137,7 +127,6 @@ class Ranking(models.Model): return '%d: %s' % (self.rank, self.author.name) -@python_2_unicode_compatible class Cover(models.Model): title = models.CharField(max_length=50) item = models.ForeignKey(Item, models.CASCADE) @@ -149,7 +138,6 @@ class Cover(models.Model): return self.title -@python_2_unicode_compatible class Number(models.Model): num = models.IntegerField() @@ -212,7 +200,6 @@ class CustomManager(models.Manager): return qs.filter(public=True, tag__name='t1') -@python_2_unicode_compatible class ManagedModel(models.Model): data = models.CharField(max_length=10) tag = models.ForeignKey(Tag, models.CASCADE) @@ -271,7 +258,6 @@ class CustomPkTag(models.Model): # path to another model, and a return path from that model. -@python_2_unicode_compatible class Celebrity(models.Model): name = models.CharField("Name", max_length=20) greatest_fan = models.ForeignKey("Fan", models.SET_NULL, null=True, unique=True) @@ -290,7 +276,6 @@ class Fan(models.Model): # Multiple foreign keys -@python_2_unicode_compatible class LeafA(models.Model): data = models.CharField(max_length=10) @@ -307,7 +292,6 @@ class Join(models.Model): b = models.ForeignKey(LeafB, models.CASCADE) -@python_2_unicode_compatible class ReservedName(models.Model): name = models.CharField(max_length=20) order = models.IntegerField() @@ -318,7 +302,6 @@ class ReservedName(models.Model): # A simpler shared-foreign-key setup that can expose some problems. -@python_2_unicode_compatible class SharedConnection(models.Model): data = models.CharField(max_length=10) @@ -336,7 +319,6 @@ class PointerB(models.Model): # Multi-layer ordering -@python_2_unicode_compatible class SingleObject(models.Model): name = models.CharField(max_length=10) @@ -355,7 +337,6 @@ class RelatedObject(models.Model): ordering = ['single'] -@python_2_unicode_compatible class Plaything(models.Model): name = models.CharField(max_length=10) others = models.ForeignKey(RelatedObject, models.SET_NULL, null=True) @@ -367,7 +348,6 @@ class Plaything(models.Model): return self.name -@python_2_unicode_compatible class Article(models.Model): name = models.CharField(max_length=20) created = models.DateTimeField() @@ -376,7 +356,6 @@ class Article(models.Model): return self.name -@python_2_unicode_compatible class Food(models.Model): name = models.CharField(max_length=20, unique=True) @@ -384,7 +363,6 @@ class Food(models.Model): return self.name -@python_2_unicode_compatible class Eaten(models.Model): food = models.ForeignKey(Food, models.SET_NULL, to_field="name", null=True) meal = models.CharField(max_length=20) @@ -393,7 +371,6 @@ class Eaten(models.Model): return "%s at %s" % (self.food, self.meal) -@python_2_unicode_compatible class Node(models.Model): num = models.IntegerField(unique=True) parent = models.ForeignKey("self", models.SET_NULL, to_field="num", null=True) @@ -404,7 +381,6 @@ class Node(models.Model): # Bug #12252 -@python_2_unicode_compatible class ObjectA(models.Model): name = models.CharField(max_length=50) @@ -425,7 +401,6 @@ class ChildObjectA(ObjectA): pass -@python_2_unicode_compatible class ObjectB(models.Model): name = models.CharField(max_length=50) objecta = models.ForeignKey(ObjectA, models.CASCADE) @@ -440,7 +415,6 @@ class ProxyObjectB(ObjectB): proxy = True -@python_2_unicode_compatible class ObjectC(models.Model): name = models.CharField(max_length=50) objecta = models.ForeignKey(ObjectA, models.SET_NULL, null=True) @@ -451,7 +425,6 @@ class ObjectC(models.Model): return self.name -@python_2_unicode_compatible class SimpleCategory(models.Model): name = models.CharField(max_length=15) @@ -459,7 +432,6 @@ class SimpleCategory(models.Model): return self.name -@python_2_unicode_compatible class SpecialCategory(SimpleCategory): special_name = models.CharField(max_length=15) @@ -467,7 +439,6 @@ class SpecialCategory(SimpleCategory): return self.name + " " + self.special_name -@python_2_unicode_compatible class CategoryItem(models.Model): category = models.ForeignKey(SimpleCategory, models.CASCADE) @@ -475,7 +446,6 @@ class CategoryItem(models.Model): return "category item: " + str(self.category) -@python_2_unicode_compatible class OneToOneCategory(models.Model): new_name = models.CharField(max_length=15) category = models.OneToOneField(SimpleCategory, models.CASCADE) @@ -515,7 +485,6 @@ class ModelA(models.Model): d = models.ForeignKey(ModelD, models.CASCADE) -@python_2_unicode_compatible class Job(models.Model): name = models.CharField(max_length=20, unique=True) @@ -528,7 +497,6 @@ class JobResponsibilities(models.Model): responsibility = models.ForeignKey('Responsibility', models.CASCADE, to_field='description') -@python_2_unicode_compatible class Responsibility(models.Model): description = models.CharField(max_length=20, unique=True) jobs = models.ManyToManyField(Job, through=JobResponsibilities, @@ -561,7 +529,6 @@ class BaseA(models.Model): c = models.ForeignKey(FK3, models.SET_NULL, null=True) -@python_2_unicode_compatible class Identifier(models.Model): name = models.CharField(max_length=100) @@ -605,7 +572,6 @@ class MyObject(models.Model): # Models for #17600 regressions -@python_2_unicode_compatible class Order(models.Model): id = models.IntegerField(primary_key=True) @@ -616,7 +582,6 @@ class Order(models.Model): return '%s' % self.pk -@python_2_unicode_compatible class OrderItem(models.Model): order = models.ForeignKey(Order, models.CASCADE, related_name='items') status = models.IntegerField() @@ -632,7 +597,6 @@ class BaseUser(models.Model): pass -@python_2_unicode_compatible class Task(models.Model): title = models.CharField(max_length=10) owner = models.ForeignKey(BaseUser, models.CASCADE, related_name='owner') @@ -642,7 +606,6 @@ class Task(models.Model): return self.title -@python_2_unicode_compatible class Staff(models.Model): name = models.CharField(max_length=10) @@ -650,7 +613,6 @@ class Staff(models.Model): return self.name -@python_2_unicode_compatible class StaffUser(BaseUser): staff = models.OneToOneField(Staff, models.CASCADE, related_name='user') @@ -673,7 +635,6 @@ class Person(models.Model): name = models.CharField(max_length=128) -@python_2_unicode_compatible class Company(models.Model): name = models.CharField(max_length=128) employees = models.ManyToManyField(Person, related_name='employers', through='Employment') diff --git a/tests/reserved_names/models.py b/tests/reserved_names/models.py index e3806ab550..4548f78e7e 100644 --- a/tests/reserved_names/models.py +++ b/tests/reserved_names/models.py @@ -8,10 +8,8 @@ reserved-name usage. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Thing(models.Model): when = models.CharField(max_length=1, primary_key=True) join = models.CharField(max_length=1) diff --git a/tests/reverse_lookup/models.py b/tests/reverse_lookup/models.py index 51e879bf68..e7db427255 100644 --- a/tests/reverse_lookup/models.py +++ b/tests/reverse_lookup/models.py @@ -5,10 +5,8 @@ This demonstrates the reverse lookup features of the database API. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class User(models.Model): name = models.CharField(max_length=200) @@ -16,7 +14,6 @@ class User(models.Model): return self.name -@python_2_unicode_compatible class Poll(models.Model): question = models.CharField(max_length=200) creator = models.ForeignKey(User, models.CASCADE) @@ -25,7 +22,6 @@ class Poll(models.Model): return self.question -@python_2_unicode_compatible class Choice(models.Model): name = models.CharField(max_length=100) poll = models.ForeignKey(Poll, models.CASCADE, related_name="poll_choice") diff --git a/tests/save_delete_hooks/models.py b/tests/save_delete_hooks/models.py index 3d229daada..3573112cfa 100644 --- a/tests/save_delete_hooks/models.py +++ b/tests/save_delete_hooks/models.py @@ -5,10 +5,8 @@ To execute arbitrary code around ``save()`` and ``delete()``, just subclass the methods. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Person(models.Model): first_name = models.CharField(max_length=20) last_name = models.CharField(max_length=20) diff --git a/tests/schema/models.py b/tests/schema/models.py index 7d13c775a3..e8a5f1c20f 100644 --- a/tests/schema/models.py +++ b/tests/schema/models.py @@ -1,6 +1,5 @@ from django.apps.registry import Apps from django.db import models -from django.utils.encoding import python_2_unicode_compatible # Because we want to test creation and deletion of these as separate things, # these models are all inserted into a separate Apps so the main test @@ -160,7 +159,6 @@ class TagUniqueRename(models.Model): # Based on tests/reserved_names/models.py -@python_2_unicode_compatible class Thing(models.Model): when = models.CharField(max_length=1, primary_key=True) diff --git a/tests/select_related/models.py b/tests/select_related/models.py index bef2873731..c8ecf831ba 100644 --- a/tests/select_related/models.py +++ b/tests/select_related/models.py @@ -12,13 +12,11 @@ from django.contrib.contenttypes.fields import ( ) from django.contrib.contenttypes.models import ContentType from django.db import models -from django.utils.encoding import python_2_unicode_compatible # Who remembers high school biology? -@python_2_unicode_compatible class Domain(models.Model): name = models.CharField(max_length=50) @@ -26,7 +24,6 @@ class Domain(models.Model): return self.name -@python_2_unicode_compatible class Kingdom(models.Model): name = models.CharField(max_length=50) domain = models.ForeignKey(Domain, models.CASCADE) @@ -35,7 +32,6 @@ class Kingdom(models.Model): return self.name -@python_2_unicode_compatible class Phylum(models.Model): name = models.CharField(max_length=50) kingdom = models.ForeignKey(Kingdom, models.CASCADE) @@ -44,7 +40,6 @@ class Phylum(models.Model): return self.name -@python_2_unicode_compatible class Klass(models.Model): name = models.CharField(max_length=50) phylum = models.ForeignKey(Phylum, models.CASCADE) @@ -53,7 +48,6 @@ class Klass(models.Model): return self.name -@python_2_unicode_compatible class Order(models.Model): name = models.CharField(max_length=50) klass = models.ForeignKey(Klass, models.CASCADE) @@ -62,7 +56,6 @@ class Order(models.Model): return self.name -@python_2_unicode_compatible class Family(models.Model): name = models.CharField(max_length=50) order = models.ForeignKey(Order, models.CASCADE) @@ -71,7 +64,6 @@ class Family(models.Model): return self.name -@python_2_unicode_compatible class Genus(models.Model): name = models.CharField(max_length=50) family = models.ForeignKey(Family, models.CASCADE) @@ -80,7 +72,6 @@ class Genus(models.Model): return self.name -@python_2_unicode_compatible class Species(models.Model): name = models.CharField(max_length=50) genus = models.ForeignKey(Genus, models.CASCADE) @@ -91,7 +82,6 @@ class Species(models.Model): # and we'll invent a new thing so we have a model with two foreign keys -@python_2_unicode_compatible class HybridSpecies(models.Model): name = models.CharField(max_length=50) parent_1 = models.ForeignKey(Species, models.CASCADE, related_name='child_1') @@ -101,7 +91,6 @@ class HybridSpecies(models.Model): return self.name -@python_2_unicode_compatible class Topping(models.Model): name = models.CharField(max_length=30) @@ -109,7 +98,6 @@ class Topping(models.Model): return self.name -@python_2_unicode_compatible class Pizza(models.Model): name = models.CharField(max_length=100) toppings = models.ManyToManyField(Topping) @@ -118,7 +106,6 @@ class Pizza(models.Model): return self.name -@python_2_unicode_compatible class TaggedItem(models.Model): tag = models.CharField(max_length=30) @@ -130,7 +117,6 @@ class TaggedItem(models.Model): return self.tag -@python_2_unicode_compatible class Bookmark(models.Model): url = models.URLField() tags = GenericRelation(TaggedItem) diff --git a/tests/select_related_onetoone/models.py b/tests/select_related_onetoone/models.py index 76c45659af..0a20cc7375 100644 --- a/tests/select_related_onetoone/models.py +++ b/tests/select_related_onetoone/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class User(models.Model): username = models.CharField(max_length=100) email = models.EmailField() @@ -11,7 +9,6 @@ class User(models.Model): return self.username -@python_2_unicode_compatible class UserProfile(models.Model): user = models.OneToOneField(User, models.CASCADE) city = models.CharField(max_length=100) @@ -21,7 +18,6 @@ class UserProfile(models.Model): return "%s, %s" % (self.city, self.state) -@python_2_unicode_compatible class UserStatResult(models.Model): results = models.CharField(max_length=50) @@ -29,7 +25,6 @@ class UserStatResult(models.Model): return 'UserStatResults, results = %s' % (self.results,) -@python_2_unicode_compatible class UserStat(models.Model): user = models.OneToOneField(User, models.CASCADE, primary_key=True) posts = models.IntegerField() @@ -39,7 +34,6 @@ class UserStat(models.Model): return 'UserStat, posts = %s' % (self.posts,) -@python_2_unicode_compatible class StatDetails(models.Model): base_stats = models.OneToOneField(UserStat, models.CASCADE) comments = models.IntegerField() @@ -61,7 +55,6 @@ class Product(models.Model): image = models.OneToOneField(Image, models.SET_NULL, null=True) -@python_2_unicode_compatible class Parent1(models.Model): name1 = models.CharField(max_length=50) @@ -69,7 +62,6 @@ class Parent1(models.Model): return self.name1 -@python_2_unicode_compatible class Parent2(models.Model): # Avoid having two "id" fields in the Child1 subclass id2 = models.AutoField(primary_key=True) @@ -79,7 +71,6 @@ class Parent2(models.Model): return self.name2 -@python_2_unicode_compatible class Child1(Parent1, Parent2): value = models.IntegerField() @@ -87,7 +78,6 @@ class Child1(Parent1, Parent2): return self.name1 -@python_2_unicode_compatible class Child2(Parent1): parent2 = models.OneToOneField(Parent2, models.CASCADE) value = models.IntegerField() diff --git a/tests/select_related_regress/models.py b/tests/select_related_regress/models.py index 4ac8cc1518..ed4d98544b 100644 --- a/tests/select_related_regress/models.py +++ b/tests/select_related_regress/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Building(models.Model): name = models.CharField(max_length=10) @@ -10,7 +8,6 @@ class Building(models.Model): return "Building: %s" % self.name -@python_2_unicode_compatible class Device(models.Model): building = models.ForeignKey('Building', models.CASCADE) name = models.CharField(max_length=10) @@ -19,7 +16,6 @@ class Device(models.Model): return "device '%s' in building %s" % (self.name, self.building) -@python_2_unicode_compatible class Port(models.Model): device = models.ForeignKey('Device', models.CASCADE) port_number = models.CharField(max_length=10) @@ -28,7 +24,6 @@ class Port(models.Model): return "%s/%s" % (self.device.name, self.port_number) -@python_2_unicode_compatible class Connection(models.Model): start = models.ForeignKey( Port, @@ -102,7 +97,6 @@ class SpecialClient(Client): # Some model inheritance exercises -@python_2_unicode_compatible class Parent(models.Model): name = models.CharField(max_length=10) @@ -114,7 +108,6 @@ class Child(Parent): value = models.IntegerField() -@python_2_unicode_compatible class Item(models.Model): name = models.CharField(max_length=10) child = models.ForeignKey(Child, models.SET_NULL, null=True) @@ -125,7 +118,6 @@ class Item(models.Model): # Models for testing bug #19870. -@python_2_unicode_compatible class Fowl(models.Model): name = models.CharField(max_length=10) diff --git a/tests/serializers/models/base.py b/tests/serializers/models/base.py index 5f9bdd833c..aa55b87c61 100644 --- a/tests/serializers/models/base.py +++ b/tests/serializers/models/base.py @@ -8,7 +8,6 @@ from decimal import Decimal from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible class CategoryMetaDataManager(models.Manager): @@ -17,7 +16,6 @@ class CategoryMetaDataManager(models.Manager): return self.get(kind=kind, name=name) -@python_2_unicode_compatible class CategoryMetaData(models.Model): kind = models.CharField(max_length=10) name = models.CharField(max_length=10) @@ -34,7 +32,6 @@ class CategoryMetaData(models.Model): return (self.kind, self.name) -@python_2_unicode_compatible class Category(models.Model): name = models.CharField(max_length=20) meta_data = models.ForeignKey(CategoryMetaData, models.SET_NULL, null=True, default=None) @@ -46,7 +43,6 @@ class Category(models.Model): return self.name -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=20) @@ -57,7 +53,6 @@ class Author(models.Model): return self.name -@python_2_unicode_compatible class Article(models.Model): author = models.ForeignKey(Author, models.CASCADE) headline = models.CharField(max_length=50) @@ -72,7 +67,6 @@ class Article(models.Model): return self.headline -@python_2_unicode_compatible class AuthorProfile(models.Model): author = models.OneToOneField(Author, models.CASCADE, primary_key=True) date_of_birth = models.DateField() @@ -81,7 +75,6 @@ class AuthorProfile(models.Model): return "Profile of %s" % self.author -@python_2_unicode_compatible class Actor(models.Model): name = models.CharField(max_length=20, primary_key=True) @@ -92,7 +85,6 @@ class Actor(models.Model): return self.name -@python_2_unicode_compatible class Movie(models.Model): actor = models.ForeignKey(Actor, models.CASCADE) title = models.CharField(max_length=50) @@ -109,7 +101,6 @@ class Score(models.Model): score = models.FloatField() -@python_2_unicode_compatible class Team(object): def __init__(self, title): self.title = title @@ -146,7 +137,6 @@ class TeamField(models.CharField): return name, path, args, kwargs -@python_2_unicode_compatible class Player(models.Model): name = models.CharField(max_length=50) rank = models.IntegerField() diff --git a/tests/signals/models.py b/tests/signals/models.py index 4f8d72817c..960df390de 100644 --- a/tests/signals/models.py +++ b/tests/signals/models.py @@ -2,10 +2,8 @@ Testing signals before/after saving and deleting. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Person(models.Model): first_name = models.CharField(max_length=20) last_name = models.CharField(max_length=20) @@ -14,7 +12,6 @@ class Person(models.Model): return "%s %s" % (self.first_name, self.last_name) -@python_2_unicode_compatible class Car(models.Model): make = models.CharField(max_length=20) model = models.CharField(max_length=20) @@ -23,7 +20,6 @@ class Car(models.Model): return "%s %s" % (self.make, self.model) -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=20) @@ -31,7 +27,6 @@ class Author(models.Model): return self.name -@python_2_unicode_compatible class Book(models.Model): name = models.CharField(max_length=20) authors = models.ManyToManyField(Author) diff --git a/tests/sites_framework/models.py b/tests/sites_framework/models.py index ed0f4443a1..fb6a9d4e79 100644 --- a/tests/sites_framework/models.py +++ b/tests/sites_framework/models.py @@ -1,10 +1,8 @@ from django.contrib.sites.managers import CurrentSiteManager from django.contrib.sites.models import Site from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class AbstractArticle(models.Model): title = models.CharField(max_length=50) diff --git a/tests/str/models.py b/tests/str/models.py index 33e31857fa..12f0247570 100644 --- a/tests/str/models.py +++ b/tests/str/models.py @@ -14,7 +14,6 @@ if you prefer. You must be careful to encode the results correctly, though. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible class Article(models.Model): @@ -27,7 +26,6 @@ class Article(models.Model): return self.headline -@python_2_unicode_compatible class InternationalArticle(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateTimeField() diff --git a/tests/str/tests.py b/tests/str/tests.py index 516560415c..c4dd1d6b26 100644 --- a/tests/str/tests.py +++ b/tests/str/tests.py @@ -25,13 +25,7 @@ class SimpleTests(TestCase): headline='Girl wins €12.500 in lottery', pub_date=datetime.datetime(2005, 7, 28) ) - if six.PY3: - self.assertEqual(str(a), 'Girl wins €12.500 in lottery') - else: - # On Python 2, the default str() output will be the UTF-8 encoded - # output of __unicode__() -- or __str__() when the - # python_2_unicode_compatible decorator is used. - self.assertEqual(str(a), b'Girl wins \xe2\x82\xac12.500 in lottery') + self.assertEqual(str(a), 'Girl wins €12.500 in lottery') @isolate_apps('str') def test_defaults(self): diff --git a/tests/string_lookup/models.py b/tests/string_lookup/models.py index e8fd8a1b12..5351ee5fe9 100644 --- a/tests/string_lookup/models.py +++ b/tests/string_lookup/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Foo(models.Model): name = models.CharField(max_length=50) friend = models.CharField(max_length=50, blank=True) @@ -11,7 +9,6 @@ class Foo(models.Model): return "Foo %s" % self.name -@python_2_unicode_compatible class Bar(models.Model): name = models.CharField(max_length=50) normal = models.ForeignKey(Foo, models.CASCADE, related_name='normal_foo') @@ -22,7 +19,6 @@ class Bar(models.Model): return "Bar %s" % self.place.name -@python_2_unicode_compatible class Whiz(models.Model): name = models.CharField(max_length=50) @@ -30,7 +26,6 @@ class Whiz(models.Model): return "Whiz %s" % self.name -@python_2_unicode_compatible class Child(models.Model): parent = models.OneToOneField('Base', models.CASCADE) name = models.CharField(max_length=50) @@ -39,7 +34,6 @@ class Child(models.Model): return "Child %s" % self.name -@python_2_unicode_compatible class Base(models.Model): name = models.CharField(max_length=50) @@ -47,7 +41,6 @@ class Base(models.Model): return "Base %s" % self.name -@python_2_unicode_compatible class Article(models.Model): name = models.CharField(max_length=50) text = models.TextField() diff --git a/tests/syndication_tests/models.py b/tests/syndication_tests/models.py index 22b0f81fbb..f6c499ccca 100644 --- a/tests/syndication_tests/models.py +++ b/tests/syndication_tests/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Entry(models.Model): title = models.CharField(max_length=200) updated = models.DateTimeField() @@ -18,7 +16,6 @@ class Entry(models.Model): return "/blog/%s/" % self.pk -@python_2_unicode_compatible class Article(models.Model): title = models.CharField(max_length=200) entry = models.ForeignKey(Entry, models.CASCADE) diff --git a/tests/template_tests/filter_tests/test_unordered_list.py b/tests/template_tests/filter_tests/test_unordered_list.py index eab9442780..659b1acc2b 100644 --- a/tests/template_tests/filter_tests/test_unordered_list.py +++ b/tests/template_tests/filter_tests/test_unordered_list.py @@ -1,6 +1,5 @@ from django.template.defaultfilters import unordered_list from django.test import SimpleTestCase -from django.utils.encoding import python_2_unicode_compatible from django.utils.safestring import mark_safe from ..utils import setup @@ -88,7 +87,6 @@ class FunctionTests(SimpleTestCase): ) def test_ulitem(self): - @python_2_unicode_compatible class ULItem(object): def __init__(self, title): self.title = title @@ -115,7 +113,6 @@ class FunctionTests(SimpleTestCase): ) def test_ulitem_autoescape_off(self): - @python_2_unicode_compatible class ULItem(object): def __init__(self, title): self.title = title diff --git a/tests/template_tests/utils.py b/tests/template_tests/utils.py index cbc452c808..187d259f36 100644 --- a/tests/template_tests/utils.py +++ b/tests/template_tests/utils.py @@ -4,7 +4,6 @@ import os from django.template.engine import Engine from django.test.utils import override_settings from django.utils._os import upath -from django.utils.encoding import python_2_unicode_compatible from django.utils.safestring import mark_safe ROOT = os.path.dirname(os.path.abspath(upath(__file__))) @@ -165,7 +164,6 @@ class SilentAttrClass(object): b = property(b) -@python_2_unicode_compatible class UTF8Class: "Class whose __str__ returns non-ASCII data on Python 2" def __str__(self): @@ -173,13 +171,11 @@ class UTF8Class: # These two classes are used to test auto-escaping of unicode output. -@python_2_unicode_compatible class UnsafeClass: def __str__(self): return 'you & me' -@python_2_unicode_compatible class SafeClass: def __str__(self): return mark_safe('you > me') diff --git a/tests/test_utils/models.py b/tests/test_utils/models.py index 979b04855f..e94d44356b 100644 --- a/tests/test_utils/models.py +++ b/tests/test_utils/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Car(models.Model): name = models.CharField(max_length=100) @@ -10,7 +8,6 @@ class Car(models.Model): return self.name -@python_2_unicode_compatible class Person(models.Model): name = models.CharField(max_length=100) cars = models.ManyToManyField(Car, through='PossessedCar') @@ -19,7 +16,6 @@ class Person(models.Model): return self.name -@python_2_unicode_compatible class PossessedCar(models.Model): car = models.ForeignKey(Car, models.CASCADE) belongs_to = models.ForeignKey(Person, models.CASCADE) diff --git a/tests/transaction_hooks/models.py b/tests/transaction_hooks/models.py index cd2f22b514..d3abbfef91 100644 --- a/tests/transaction_hooks/models.py +++ b/tests/transaction_hooks/models.py @@ -1,8 +1,6 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Thing(models.Model): num = models.IntegerField() diff --git a/tests/transactions/models.py b/tests/transactions/models.py index 4154b39123..2f2bac463a 100644 --- a/tests/transactions/models.py +++ b/tests/transactions/models.py @@ -7,10 +7,8 @@ commit-on-success behavior. Alternatively, you can manage the transaction manually. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Reporter(models.Model): first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=30) diff --git a/tests/unmanaged_models/models.py b/tests/unmanaged_models/models.py index e925752a06..13824b7732 100644 --- a/tests/unmanaged_models/models.py +++ b/tests/unmanaged_models/models.py @@ -4,13 +4,11 @@ is generated for the table on various manage.py operations. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible # All of these models are created in the database by Django. -@python_2_unicode_compatible class A01(models.Model): f_a = models.CharField(max_length=10, db_index=True) f_b = models.IntegerField() @@ -22,7 +20,6 @@ class A01(models.Model): return self.f_a -@python_2_unicode_compatible class B01(models.Model): fk_a = models.ForeignKey(A01, models.CASCADE) f_a = models.CharField(max_length=10, db_index=True) @@ -37,7 +34,6 @@ class B01(models.Model): return self.f_a -@python_2_unicode_compatible class C01(models.Model): mm_a = models.ManyToManyField(A01, db_table='d01') f_a = models.CharField(max_length=10, db_index=True) @@ -54,7 +50,6 @@ class C01(models.Model): # since we have told Django they aren't managed by Django. -@python_2_unicode_compatible class A02(models.Model): f_a = models.CharField(max_length=10, db_index=True) @@ -66,7 +61,6 @@ class A02(models.Model): return self.f_a -@python_2_unicode_compatible class B02(models.Model): class Meta: db_table = 'b01' @@ -82,7 +76,6 @@ class B02(models.Model): # To re-use the many-to-many intermediate table, we need to manually set up # things up. -@python_2_unicode_compatible class C02(models.Model): mm_a = models.ManyToManyField(A02, through="Intermediate") f_a = models.CharField(max_length=10, db_index=True) diff --git a/tests/update/models.py b/tests/update/models.py index 648a773318..1fbab38ca9 100644 --- a/tests/update/models.py +++ b/tests/update/models.py @@ -5,10 +5,8 @@ updates. from django.db import models from django.utils import six -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class DataPoint(models.Model): name = models.CharField(max_length=20) value = models.CharField(max_length=20) @@ -18,7 +16,6 @@ class DataPoint(models.Model): return six.text_type(self.name) -@python_2_unicode_compatible class RelatedPoint(models.Model): name = models.CharField(max_length=20) data = models.ForeignKey(DataPoint, models.CASCADE) diff --git a/tests/update_only_fields/models.py b/tests/update_only_fields/models.py index a3be5088a2..3d6a9ec8e6 100644 --- a/tests/update_only_fields/models.py +++ b/tests/update_only_fields/models.py @@ -1,6 +1,5 @@ from django.db import models -from django.utils.encoding import python_2_unicode_compatible GENDER_CHOICES = ( ('M', 'Male'), @@ -12,7 +11,6 @@ class Account(models.Model): num = models.IntegerField() -@python_2_unicode_compatible class Person(models.Model): name = models.CharField(max_length=20) gender = models.CharField(max_length=1, choices=GENDER_CHOICES) @@ -28,7 +26,6 @@ class Employee(Person): accounts = models.ManyToManyField('Account', related_name='employees', blank=True) -@python_2_unicode_compatible class Profile(models.Model): name = models.CharField(max_length=200) salary = models.FloatField(default=1000.0) diff --git a/tests/validation/models.py b/tests/validation/models.py index 90b2dbb79a..043aa4ded7 100644 --- a/tests/validation/models.py +++ b/tests/validation/models.py @@ -2,7 +2,6 @@ from datetime import datetime from django.core.exceptions import ValidationError from django.db import models -from django.utils.encoding import python_2_unicode_compatible def validate_answer_to_universe(value): @@ -89,7 +88,6 @@ class Article(models.Model): self.pub_date = datetime.now() -@python_2_unicode_compatible class Post(models.Model): title = models.CharField(max_length=50, unique_for_date='posted', blank=True) slug = models.CharField(max_length=50, unique_for_year='posted', blank=True) diff --git a/tests/view_tests/models.py b/tests/view_tests/models.py index c891bcadee..04e31c43da 100644 --- a/tests/view_tests/models.py +++ b/tests/view_tests/models.py @@ -3,10 +3,8 @@ Regression tests for Django built-in views. """ from django.db import models -from django.utils.encoding import python_2_unicode_compatible -@python_2_unicode_compatible class Author(models.Model): name = models.CharField(max_length=100) @@ -17,7 +15,6 @@ class Author(models.Model): return '/authors/%s/' % self.id -@python_2_unicode_compatible class BaseArticle(models.Model): """ An abstract article Model so that we can create article models with and