mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
Refs #23919 -- Removed python_2_unicode_compatible decorator usage
This commit is contained in:
parent
d7b9aaa366
commit
f3c43ad1fd
@ -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'),
|
||||
|
@ -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."
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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'))
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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('<Deferred field>')
|
||||
|
@ -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"""
|
||||
|
||||
|
@ -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
|
||||
|
@ -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',
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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:
|
||||
|
@ -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=()):
|
||||
|
@ -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, ())
|
||||
|
@ -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):
|
||||
|
||||
|
@ -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):
|
||||
|
@ -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__()``
|
||||
------------
|
||||
|
||||
|
@ -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()``
|
||||
-------------------------------------
|
||||
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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')
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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')
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
8
tests/fixtures/models.py
vendored
8
tests/fixtures/models.py
vendored
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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`
|
||||
|
@ -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',
|
||||
|
@ -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(
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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.</p>
|
||||
)
|
||||
|
||||
def test_errorlist_override(self):
|
||||
@python_2_unicode_compatible
|
||||
class DivErrorList(ErrorList):
|
||||
def __str__(self):
|
||||
return self.as_divs()
|
||||
|
@ -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):
|
||||
'</ul>'
|
||||
)
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class VeryBadError:
|
||||
def __str__(self):
|
||||
return "A very bad error."
|
||||
|
@ -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('<a href="https://www.python.org/">value</a>', html)
|
||||
|
||||
def test_return_false_if_url_does_not_exists(self):
|
||||
@python_2_unicode_compatible
|
||||
class NoURLFieldFile(object):
|
||||
def __str__(self):
|
||||
return 'value'
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user