Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #17627 -- Renamed util.py files to utils.py

Thanks PaulM for the suggestion and Luke Granger-Brown and
Wiktor Kołodziej for the initial patch.
  • Loading branch information...
commit 18ffdb1772ba60e085cff8fd9a1d4a7b129b4032 1 parent 8d29005
@timgraham timgraham authored
Showing with 111 additions and 84 deletions.
  1. +2 −0  AUTHORS
  2. +1 −1  django/contrib/admin/actions.py
  3. +1 −1  django/contrib/admin/filters.py
  4. +3 −3 django/contrib/admin/helpers.py
  5. +1 −1  django/contrib/admin/models.py
  6. +1 −1  django/contrib/admin/options.py
  7. +1 −1  django/contrib/admin/templatetags/admin_list.py
  8. +1 −1  django/contrib/admin/templatetags/admin_urls.py
  9. 0  django/contrib/admin/{util.py → utils.py}
  10. +1 −1  django/contrib/admin/validation.py
  11. +1 −1  django/contrib/admin/views/main.py
  12. +1 −1  django/contrib/admin/widgets.py
  13. +1 −1  django/contrib/auth/forms.py
  14. +1 −1  django/contrib/comments/forms.py
  15. +1 −1  django/contrib/gis/db/backends/oracle/creation.py
  16. +1 −1  django/contrib/gis/db/backends/oracle/operations.py
  17. +1 −1  django/contrib/gis/db/backends/postgis/operations.py
  18. +1 −1  django/contrib/gis/db/backends/spatialite/operations.py
  19. 0  django/contrib/gis/db/backends/{util.py → utils.py}
  20. +1 −1  django/contrib/gis/db/models/sql/compiler.py
  21. +4 −4 django/db/backends/__init__.py
  22. +1 −1  django/db/backends/creation.py
  23. +5 −5 django/db/backends/mysql/base.py
  24. +1 −1  django/db/backends/mysql/creation.py
  25. +6 −5 django/db/backends/oracle/base.py
  26. +1 −1  django/db/backends/postgresql_psycopg2/creation.py
  27. +1 −1  django/db/backends/schema.py
  28. +9 −9 django/db/backends/sqlite3/base.py
  29. 0  django/db/backends/{util.py → utils.py}
  30. +3 −3 django/db/models/fields/__init__.py
  31. +2 −2 django/db/models/fields/related.py
  32. +1 −1  django/db/models/options.py
  33. +2 −2 django/db/models/query_utils.py
  34. +3 −3 django/db/models/sql/compiler.py
  35. +1 −1  django/forms/fields.py
  36. +1 −1  django/forms/forms.py
  37. +1 −1  django/forms/formsets.py
  38. +1 −1  django/forms/models.py
  39. 0  django/forms/{util.py → utils.py}
  40. +1 −1  django/forms/widgets.py
  41. +9 −0 docs/internals/deprecation.txt
  42. +6 −2 docs/ref/forms/api.txt
  43. +2 −2 docs/ref/forms/validation.txt
  44. +11 −0 docs/releases/1.7.txt
  45. +1 −1  docs/topics/forms/formsets.txt
  46. +1 −1  tests/admin_custom_urls/tests.py
  47. +1 −1  tests/admin_util/tests.py
  48. +1 −1  tests/admin_views/admin.py
  49. +2 −2 tests/admin_views/tests.py
  50. +1 −1  tests/backends/tests.py
  51. +1 −1  tests/db_typecasts/tests.py
  52. +1 −1  tests/forms_tests/tests/test_error_messages.py
  53. +1 −1  tests/forms_tests/tests/test_extra.py
  54. +3 −3 tests/forms_tests/tests/test_fields.py
  55. +1 −1  tests/forms_tests/tests/test_formsets.py
  56. +2 −2 tests/forms_tests/tests/test_util.py
  57. +1 −1  tests/model_formsets_regress/tests.py
  58. +1 −1  tests/proxy_models/tests.py
View
2  AUTHORS
@@ -264,6 +264,7 @@ answer newbie questions, and generally made Django that much better:
David Gouldin <dgouldin@gmail.com>
pradeep.gowda@gmail.com
Collin Grady <collin@collingrady.com>
+ Luke Granger-Brown <django@lukegb.com>
Gabriel Grant <g@briel.ca>
Martin Green
Daniel Greenfeld
@@ -348,6 +349,7 @@ answer newbie questions, and generally made Django that much better:
Cameron Knight (ckknight)
Nena Kojadin <nena@kiberpipa.org>
Igor Kolar <ike@email.si>
+ Wiktor Kołodziej
Tomáš Kopeček <permonik@m6.cz>
Gasper Koren
Mikhail Korobov <kmike84@googlemail.com>
View
2  django/contrib/admin/actions.py
@@ -5,7 +5,7 @@
from django.core.exceptions import PermissionDenied
from django.contrib import messages
from django.contrib.admin import helpers
-from django.contrib.admin.util import get_deleted_objects, model_ngettext
+from django.contrib.admin.utils import get_deleted_objects, model_ngettext
from django.db import router
from django.template.response import TemplateResponse
from django.utils.encoding import force_text
View
2  django/contrib/admin/filters.py
@@ -12,7 +12,7 @@
from django.utils.encoding import smart_text, force_text
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
-from django.contrib.admin.util import (get_model_from_relation,
+from django.contrib.admin.utils import (get_model_from_relation,
reverse_field_path, get_limit_choices_to_from_path, prepare_lookup_value)
from django.contrib.admin.options import IncorrectLookupParameters
View
6 django/contrib/admin/helpers.py
@@ -1,13 +1,13 @@
from __future__ import unicode_literals
from django import forms
-from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
+from django.contrib.admin.utils import (flatten_fieldsets, lookup_field,
display_for_field, label_for_field, help_text_for_field)
from django.contrib.admin.templatetags.admin_static import static
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.fields.related import ManyToManyRel
-from django.forms.util import flatatt
+from django.forms.utils import flatatt
from django.template.defaultfilters import capfirst
from django.utils.encoding import force_text, smart_text
from django.utils.html import conditional_escape, format_html
@@ -308,7 +308,7 @@ def __iter__(self):
yield Fieldline(self.form, field, self.readonly_fields,
model_admin=self.model_admin)
-class AdminErrorList(forms.util.ErrorList):
+class AdminErrorList(forms.utils.ErrorList):
"""
Stores all errors for the form/formsets in an add/change stage view.
"""
View
2  django/contrib/admin/models.py
@@ -3,7 +3,7 @@
from django.db import models
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
-from django.contrib.admin.util import quote
+from django.contrib.admin.utils import quote
from django.core.urlresolvers import reverse, NoReverseMatch
from django.utils.translation import ugettext, ugettext_lazy as _
from django.utils.encoding import smart_text
View
2  django/contrib/admin/options.py
@@ -8,7 +8,7 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.admin import widgets, helpers
-from django.contrib.admin.util import (unquote, flatten_fieldsets, get_deleted_objects,
+from django.contrib.admin.utils import (unquote, flatten_fieldsets, get_deleted_objects,
model_format_dict, NestedObjects, lookup_needs_distinct)
from django.contrib.admin import validation
from django.contrib.admin.templatetags.admin_static import static
View
2  django/contrib/admin/templatetags/admin_list.py
@@ -3,7 +3,7 @@
import datetime
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
-from django.contrib.admin.util import (lookup_field, display_for_field,
+from django.contrib.admin.utils import (lookup_field, display_for_field,
display_for_value, label_for_field)
from django.contrib.admin.views.main import (ALL_VAR, EMPTY_CHANGELIST_VALUE,
ORDER_VAR, PAGE_VAR, SEARCH_VAR)
View
2  django/contrib/admin/templatetags/admin_urls.py
@@ -4,7 +4,7 @@
from urlparse import parse_qsl, urlparse, urlunparse
from django import template
-from django.contrib.admin.util import quote
+from django.contrib.admin.utils import quote
from django.core.urlresolvers import resolve, Resolver404
from django.utils.http import urlencode
View
0  django/contrib/admin/util.py → django/contrib/admin/utils.py
File renamed without changes
View
2  django/contrib/admin/validation.py
@@ -2,7 +2,7 @@
from django.db import models
from django.db.models.fields import FieldDoesNotExist
from django.forms.models import BaseModelForm, BaseModelFormSet, _get_foreign_key
-from django.contrib.admin.util import get_fields_from_path, NotRelationField
+from django.contrib.admin.utils import get_fields_from_path, NotRelationField
"""
Does basic ModelAdmin option validation. Calls custom validation
View
2  django/contrib/admin/views/main.py
@@ -16,7 +16,7 @@
from django.contrib.admin import FieldListFilter
from django.contrib.admin.exceptions import DisallowedModelAdminLookup
from django.contrib.admin.options import IncorrectLookupParameters, IS_POPUP_VAR, TO_FIELD_VAR
-from django.contrib.admin.util import (quote, get_fields_from_path,
+from django.contrib.admin.utils import (quote, get_fields_from_path,
lookup_needs_distinct, prepare_lookup_value)
# Changelist settings
View
2  django/contrib/admin/widgets.py
@@ -9,7 +9,7 @@
from django.contrib.admin.templatetags.admin_static import static
from django.core.urlresolvers import reverse
from django.forms.widgets import RadioFieldRenderer
-from django.forms.util import flatatt
+from django.forms.utils import flatatt
from django.utils.html import escape, format_html, format_html_join, smart_urlquote
from django.utils.text import Truncator
from django.utils.translation import ugettext as _
View
2  django/contrib/auth/forms.py
@@ -3,7 +3,7 @@
from collections import OrderedDict
from django import forms
-from django.forms.util import flatatt
+from django.forms.utils import flatatt
from django.template import loader
from django.utils.encoding import force_bytes
from django.utils.html import format_html, format_html_join
View
2  django/contrib/comments/forms.py
@@ -1,6 +1,6 @@
import time
from django import forms
-from django.forms.util import ErrorDict
+from django.forms.utils import ErrorDict
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.contrib.comments.models import Comment
View
2  django/contrib/gis/db/backends/oracle/creation.py
@@ -1,5 +1,5 @@
from django.db.backends.oracle.creation import DatabaseCreation
-from django.db.backends.util import truncate_name
+from django.db.backends.utils import truncate_name
class OracleCreation(DatabaseCreation):
View
2  django/contrib/gis/db/backends/oracle/operations.py
@@ -13,7 +13,7 @@
from django.db.backends.oracle.base import DatabaseOperations
from django.contrib.gis.db.backends.base import BaseSpatialOperations
from django.contrib.gis.db.backends.oracle.adapter import OracleSpatialAdapter
-from django.contrib.gis.db.backends.util import SpatialFunction
+from django.contrib.gis.db.backends.utils import SpatialFunction
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Distance
from django.utils import six
View
2  django/contrib/gis/db/backends/postgis/operations.py
@@ -3,7 +3,7 @@
from django.conf import settings
from django.contrib.gis.db.backends.base import BaseSpatialOperations
-from django.contrib.gis.db.backends.util import SpatialOperation, SpatialFunction
+from django.contrib.gis.db.backends.utils import SpatialOperation, SpatialFunction
from django.contrib.gis.db.backends.postgis.adapter import PostGISAdapter
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Distance
View
2  django/contrib/gis/db/backends/spatialite/operations.py
@@ -3,7 +3,7 @@
from decimal import Decimal
from django.contrib.gis.db.backends.base import BaseSpatialOperations
-from django.contrib.gis.db.backends.util import SpatialOperation, SpatialFunction
+from django.contrib.gis.db.backends.utils import SpatialOperation, SpatialFunction
from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Distance
View
0  django/contrib/gis/db/backends/util.py → django/contrib/gis/db/backends/utils.py
File renamed without changes
View
2  django/contrib/gis/db/models/sql/compiler.py
@@ -1,7 +1,7 @@
import datetime
from django.conf import settings
-from django.db.backends.util import truncate_name, typecast_date, typecast_timestamp
+from django.db.backends.utils import truncate_name, typecast_date, typecast_timestamp
from django.db.models.sql import compiler
from django.db.models.sql.constants import MULTI
from django.utils import six
View
8 django/db/backends/__init__.py
@@ -14,7 +14,7 @@
from django.conf import settings
from django.db import DEFAULT_DB_ALIAS
from django.db.backends.signals import connection_created
-from django.db.backends import util
+from django.db.backends import utils
from django.db.transaction import TransactionManagementError
from django.db.utils import DatabaseErrorWrapper
from django.utils.functional import cached_property
@@ -158,7 +158,7 @@ def cursor(self):
(self.use_debug_cursor is None and settings.DEBUG)):
cursor = self.make_debug_cursor(self._cursor())
else:
- cursor = util.CursorWrapper(self._cursor(), self)
+ cursor = utils.CursorWrapper(self._cursor(), self)
return cursor
def commit(self):
@@ -495,7 +495,7 @@ def make_debug_cursor(self, cursor):
"""
Creates a cursor that logs all queries in self.queries.
"""
- return util.CursorDebugWrapper(cursor, self)
+ return utils.CursorDebugWrapper(cursor, self)
@contextmanager
def temporary_connection(self):
@@ -1131,7 +1131,7 @@ def value_to_db_decimal(self, value, max_digits, decimal_places):
"""
if value is None:
return None
- return util.format_number(value, max_digits, decimal_places)
+ return utils.format_number(value, max_digits, decimal_places)
def year_lookup_bounds_for_date_field(self, value):
"""
View
2  django/db/backends/creation.py
@@ -8,7 +8,7 @@
from django.utils.encoding import force_bytes
from django.utils.six.moves import input
-from .util import truncate_name
+from .utils import truncate_name
# The prefix to put on the default database name when creating
# the test database.
View
10 django/db/backends/mysql/base.py
@@ -37,7 +37,7 @@
from django.conf import settings
from django.db import utils
-from django.db.backends import (util, BaseDatabaseFeatures,
+from django.db.backends import (utils as backend_utils, BaseDatabaseFeatures,
BaseDatabaseOperations, BaseDatabaseWrapper)
from django.db.backends.mysql.client import DatabaseClient
from django.db.backends.mysql.creation import DatabaseCreation
@@ -91,9 +91,9 @@ def adapt_datetime_with_timezone_support(value, conv):
# timezone support is active, Django expects timezone-aware datetime objects.
django_conversions = conversions.copy()
django_conversions.update({
- FIELD_TYPE.TIME: util.typecast_time,
- FIELD_TYPE.DECIMAL: util.typecast_decimal,
- FIELD_TYPE.NEWDECIMAL: util.typecast_decimal,
+ FIELD_TYPE.TIME: backend_utils.typecast_time,
+ FIELD_TYPE.DECIMAL: backend_utils.typecast_decimal,
+ FIELD_TYPE.NEWDECIMAL: backend_utils.typecast_decimal,
FIELD_TYPE.DATETIME: parse_datetime_with_timezone_support,
datetime.datetime: adapt_datetime_with_timezone_support,
})
@@ -109,7 +109,7 @@ def adapt_datetime_with_timezone_support(value, conv):
# MySQL-4.1 and newer, so the MysqlDebugWrapper is unnecessary. Since the
# point is to raise Warnings as exceptions, this can be done with the Python
# warning module, and this is setup when the connection is created, and the
-# standard util.CursorDebugWrapper can be used. Also, using sql_mode
+# standard backend_utils.CursorDebugWrapper can be used. Also, using sql_mode
# TRADITIONAL will automatically cause most warnings to be treated as errors.
class CursorWrapper(object):
View
2  django/db/backends/mysql/creation.py
@@ -61,7 +61,7 @@ def sql_destroy_indexes_for_fields(self, model, fields, style):
index_name = "%s_%s" % (model._meta.db_table, self._digest([f.name for f in fields]))
- from ..util import truncate_name
+ from ..utils import truncate_name
return [
style.SQL_KEYWORD("DROP INDEX") + " " +
View
11 django/db/backends/oracle/base.py
@@ -53,7 +53,8 @@ def _setup_environment(environ):
from django.conf import settings
from django.db import utils
-from django.db.backends import BaseDatabaseFeatures, BaseDatabaseOperations, BaseDatabaseWrapper, BaseDatabaseValidation, util
+from django.db.backends import (BaseDatabaseFeatures, BaseDatabaseOperations,
+ BaseDatabaseWrapper, BaseDatabaseValidation, utils as backend_utils)
from django.db.backends.oracle.client import DatabaseClient
from django.db.backends.oracle.creation import DatabaseCreation
from django.db.backends.oracle.introspection import DatabaseIntrospection
@@ -239,7 +240,7 @@ def convert_values(self, value, field):
value = float(value)
# Convert floats to decimals
elif value is not None and field and field.get_internal_type() == 'DecimalField':
- value = util.typecast_decimal(field.format_number(value))
+ value = backend_utils.typecast_decimal(field.format_number(value))
# cx_Oracle always returns datetime.datetime objects for
# DATE and TIMESTAMP columns, but Django wants to see a
# python datetime.date, .time, or .datetime. We use the type
@@ -316,7 +317,7 @@ def quote_name(self, name):
# always defaults to uppercase.
# We simplify things by making Oracle identifiers always uppercase.
if not name.startswith('"') and not name.endswith('"'):
- name = '"%s"' % util.truncate_name(name.upper(),
+ name = '"%s"' % backend_utils.truncate_name(name.upper(),
self.max_name_length())
# Oracle puts the query text into a (query % args) construct, so % signs
# in names need to be escaped. The '%%' will be collapsed back to '%' at
@@ -482,11 +483,11 @@ def combine_expression(self, connector, sub_expressions):
def _get_sequence_name(self, table):
name_length = self.max_name_length() - 3
- return '%s_SQ' % util.truncate_name(table, name_length).upper()
+ return '%s_SQ' % backend_utils.truncate_name(table, name_length).upper()
def _get_trigger_name(self, table):
name_length = self.max_name_length() - 3
- return '%s_TR' % util.truncate_name(table, name_length).upper()
+ return '%s_TR' % backend_utils.truncate_name(table, name_length).upper()
def bulk_insert_sql(self, fields, num_values):
items_sql = "SELECT %s FROM DUAL" % ", ".join(["%s"] * len(fields))
View
2  django/db/backends/postgresql_psycopg2/creation.py
@@ -1,5 +1,5 @@
from django.db.backends.creation import BaseDatabaseCreation
-from django.db.backends.util import truncate_name
+from django.db.backends.utils import truncate_name
class DatabaseCreation(BaseDatabaseCreation):
View
2  django/db/backends/schema.py
@@ -2,7 +2,7 @@
import operator
from django.db.backends.creation import BaseDatabaseCreation
-from django.db.backends.util import truncate_name
+from django.db.backends.utils import truncate_name
from django.db.models.fields.related import ManyToManyField
from django.db.transaction import atomic
from django.utils.log import getLogger
View
18 django/db/backends/sqlite3/base.py
@@ -13,7 +13,7 @@
from django.conf import settings
from django.db import utils
-from django.db.backends import (util, BaseDatabaseFeatures,
+from django.db.backends import (utils as backend_utils, BaseDatabaseFeatures,
BaseDatabaseOperations, BaseDatabaseWrapper, BaseDatabaseValidation)
from django.db.backends.sqlite3.client import DatabaseClient
from django.db.backends.sqlite3.creation import DatabaseCreation
@@ -80,10 +80,10 @@ def decoder(conv_func):
Database.register_converter(str("datetime"), decoder(parse_datetime_with_timezone_support))
Database.register_converter(str("timestamp"), decoder(parse_datetime_with_timezone_support))
Database.register_converter(str("TIMESTAMP"), decoder(parse_datetime_with_timezone_support))
-Database.register_converter(str("decimal"), decoder(util.typecast_decimal))
+Database.register_converter(str("decimal"), decoder(backend_utils.typecast_decimal))
Database.register_adapter(datetime.datetime, adapt_datetime_with_timezone_support)
-Database.register_adapter(decimal.Decimal, util.rev_typecast_decimal)
+Database.register_adapter(decimal.Decimal, backend_utils.rev_typecast_decimal)
if six.PY2:
Database.register_adapter(str, lambda s: s.decode('utf-8'))
Database.register_adapter(SafeBytes, lambda s: s.decode('utf-8'))
@@ -282,7 +282,7 @@ def convert_values(self, value, field):
internal_type = field.get_internal_type()
if internal_type == 'DecimalField':
- return util.typecast_decimal(field.format_number(value))
+ return backend_utils.typecast_decimal(field.format_number(value))
elif internal_type and internal_type.endswith('IntegerField') or internal_type == 'AutoField':
return int(value)
elif internal_type == 'DateField':
@@ -487,7 +487,7 @@ def _sqlite_date_extract(lookup_type, dt):
if dt is None:
return None
try:
- dt = util.typecast_timestamp(dt)
+ dt = backend_utils.typecast_timestamp(dt)
except (ValueError, TypeError):
return None
if lookup_type == 'week_day':
@@ -498,7 +498,7 @@ def _sqlite_date_extract(lookup_type, dt):
def _sqlite_date_trunc(lookup_type, dt):
try:
- dt = util.typecast_timestamp(dt)
+ dt = backend_utils.typecast_timestamp(dt)
except (ValueError, TypeError):
return None
if lookup_type == 'year':
@@ -513,7 +513,7 @@ def _sqlite_datetime_extract(lookup_type, dt, tzname):
if dt is None:
return None
try:
- dt = util.typecast_timestamp(dt)
+ dt = backend_utils.typecast_timestamp(dt)
except (ValueError, TypeError):
return None
if tzname is not None:
@@ -526,7 +526,7 @@ def _sqlite_datetime_extract(lookup_type, dt, tzname):
def _sqlite_datetime_trunc(lookup_type, dt, tzname):
try:
- dt = util.typecast_timestamp(dt)
+ dt = backend_utils.typecast_timestamp(dt)
except (ValueError, TypeError):
return None
if tzname is not None:
@@ -547,7 +547,7 @@ def _sqlite_datetime_trunc(lookup_type, dt, tzname):
def _sqlite_format_dtdelta(dt, conn, days, secs, usecs):
try:
- dt = util.typecast_timestamp(dt)
+ dt = backend_utils.typecast_timestamp(dt)
delta = datetime.timedelta(int(days), int(secs), int(usecs))
if conn.strip() == '+':
dt = dt + delta
View
0  django/db/backends/util.py → django/db/backends/utils.py
File renamed without changes
View
6 django/db/models/fields/__init__.py
@@ -1122,14 +1122,14 @@ def format_number(self, value):
Formats a number into a string with the requisite number of digits and
decimal places.
"""
- # Method moved to django.db.backends.util.
+ # Method moved to django.db.backends.utils.
#
# It is preserved because it is used by the oracle backend
# (django.db.backends.oracle.query), and also for
# backwards-compatibility with any external code which may have used
# this method.
- from django.db.backends import util
- return util.format_number(value, self.max_digits, self.decimal_places)
+ from django.db.backends import utils
+ return utils.format_number(value, self.max_digits, self.decimal_places)
def get_db_prep_save(self, value, connection):
return connection.ops.value_to_db_decimal(self.to_python(value),
View
4 django/db/models/fields/related.py
@@ -1,7 +1,7 @@
from operator import attrgetter
from django.db import connection, connections, router
-from django.db.backends import util
+from django.db.backends import utils
from django.db.models import signals
from django.db.models.fields import (AutoField, Field, IntegerField,
PositiveIntegerField, PositiveSmallIntegerField, FieldDoesNotExist)
@@ -1440,7 +1440,7 @@ def _get_m2m_db_table(self, opts):
elif self.db_table:
return self.db_table
else:
- return util.truncate_name('%s_%s' % (opts.db_table, self.name),
+ return utils.truncate_name('%s_%s' % (opts.db_table, self.name),
connection.ops.max_name_length())
def _get_m2m_attr(self, related, attr):
View
2  django/db/models/options.py
@@ -77,7 +77,7 @@ def __init__(self, meta, app_label=None):
def contribute_to_class(self, cls, name):
from django.db import connection
- from django.db.backends.util import truncate_name
+ from django.db.backends.utils import truncate_name
cls._meta = self
self.model = cls
View
4 django/db/models/query_utils.py
@@ -7,7 +7,7 @@
"""
from __future__ import unicode_literals
-from django.db.backends import util
+from django.db.backends import utils
from django.utils import six
from django.utils import tree
@@ -194,7 +194,7 @@ class Meta:
# name using the passed in attrs. It's OK to reuse an existing class
# object if the attrs are identical.
name = "%s_Deferred_%s" % (model.__name__, '_'.join(sorted(list(attrs))))
- name = util.truncate_name(name, 80, 32)
+ name = utils.truncate_name(name, 80, 32)
overrides = dict((attr, DeferredAttribute(attr, model)) for attr in attrs)
overrides["Meta"] = Meta
View
6 django/db/models/sql/compiler.py
@@ -2,7 +2,7 @@
from django.conf import settings
from django.core.exceptions import FieldError
-from django.db.backends.util import truncate_name
+from django.db.backends.utils import truncate_name
from django.db.models.constants import LOOKUP_SEP
from django.db.models.query_utils import select_related_descend, QueryWrapper
from django.db.models.sql.constants import (SINGLE, MULTI, ORDER_DIR,
@@ -1049,7 +1049,7 @@ def results_iter(self):
from django.db.models.fields import DateField
fields = [DateField()]
else:
- from django.db.backends.util import typecast_date
+ from django.db.backends.utils import typecast_date
needs_string_cast = self.connection.features.needs_datetime_string_cast
offset = len(self.query.extra_select)
@@ -1075,7 +1075,7 @@ def results_iter(self):
from django.db.models.fields import DateTimeField
fields = [DateTimeField()]
else:
- from django.db.backends.util import typecast_timestamp
+ from django.db.backends.utils import typecast_timestamp
needs_string_cast = self.connection.features.needs_datetime_string_cast
offset = len(self.query.extra_select)
View
2  django/forms/fields.py
@@ -14,7 +14,7 @@
from django.core import validators
from django.core.exceptions import ValidationError
-from django.forms.util import ErrorList, from_current_timezone, to_current_timezone
+from django.forms.utils import ErrorList, from_current_timezone, to_current_timezone
from django.forms.widgets import (
TextInput, NumberInput, EmailInput, URLInput, HiddenInput,
MultipleHiddenInput, ClearableFileInput, CheckboxInput, Select,
View
2  django/forms/forms.py
@@ -10,7 +10,7 @@
from django.core.exceptions import ValidationError
from django.forms.fields import Field, FileField
-from django.forms.util import flatatt, ErrorDict, ErrorList
+from django.forms.utils import flatatt, ErrorDict, ErrorList
from django.forms.widgets import Media, media_property, TextInput, Textarea
from django.utils.html import conditional_escape, format_html
from django.utils.encoding import smart_text, force_text, python_2_unicode_compatible
View
2  django/forms/formsets.py
@@ -3,7 +3,7 @@
from django.core.exceptions import ValidationError
from django.forms import Form
from django.forms.fields import IntegerField, BooleanField
-from django.forms.util import ErrorList
+from django.forms.utils import ErrorList
from django.forms.widgets import HiddenInput
from django.utils.encoding import python_2_unicode_compatible
from django.utils.functional import cached_property
View
2  django/forms/models.py
@@ -12,7 +12,7 @@
from django.forms.fields import Field, ChoiceField
from django.forms.forms import BaseForm, get_declared_fields
from django.forms.formsets import BaseFormSet, formset_factory
-from django.forms.util import ErrorList
+from django.forms.utils import ErrorList
from django.forms.widgets import (SelectMultiple, HiddenInput,
MultipleHiddenInput, media_property, CheckboxSelectMultiple)
from django.utils.encoding import smart_text, force_text
View
0  django/forms/util.py → django/forms/utils.py
File renamed without changes
View
2  django/forms/widgets.py
@@ -9,7 +9,7 @@
import warnings
from django.conf import settings
-from django.forms.util import flatatt, to_current_timezone
+from django.forms.utils import flatatt, to_current_timezone
from django.utils.datastructures import MultiValueDict, MergeDict
from django.utils.html import conditional_escape, format_html
from django.utils.translation import ugettext_lazy
View
9 docs/internals/deprecation.txt
@@ -444,6 +444,15 @@ these changes.
* ``ModelAdmin.declared_fieldsets`` will be removed.
+* Instances of ``util.py`` in the Django codebase have been renamed to
+ ``utils.py`` in an effort to unify all util and utils references.
+ The modules that provided backwards compatability will be removed:
+
+ * ``django.contrib.admin.util``
+ * ``django.contrib.gis.db.backends.util``
+ * ``django.db.backends.util``
+ * ``django.forms.util``
+
2.0
---
View
8 docs/ref/forms/api.txt
@@ -571,12 +571,12 @@ method you're using::
Customizing the error list format
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-By default, forms use ``django.forms.util.ErrorList`` to format validation
+By default, forms use ``django.forms.utils.ErrorList`` to format validation
errors. If you'd like to use an alternate class for displaying errors, you can
pass that in at construction time (replace ``__unicode__`` by ``__str__`` on
Python 3)::
- >>> from django.forms.util import ErrorList
+ >>> from django.forms.utils import ErrorList
>>> class DivErrorList(ErrorList):
... def __unicode__(self):
... return self.as_divs()
@@ -592,6 +592,10 @@ Python 3)::
<p>Sender: <input type="email" name="sender" value="invalid email address" /></p>
<p>Cc myself: <input checked="checked" type="checkbox" name="cc_myself" /></p>
+.. versionchanged:: 1.7
+
+ ``django.forms.util`` was renamed to ``django.forms.utils``.
+
More granular output
~~~~~~~~~~~~~~~~~~~~
View
4 docs/ref/forms/validation.txt
@@ -219,10 +219,10 @@ through the ``Form.non_field_errors()`` method.
When you really do need to attach the error to a particular field, you should
store (or amend) a key in the ``Form._errors`` attribute. This attribute is an
-instance of a ``django.forms.util.ErrorDict`` class. Essentially, though, it's
+instance of a ``django.forms.utils.ErrorDict`` class. Essentially, though, it's
just a dictionary. There is a key in the dictionary for each field in the form
that has an error. Each value in the dictionary is a
-``django.forms.util.ErrorList`` instance, which is a list that knows how to
+``django.forms.utils.ErrorList`` instance, which is a list that knows how to
display itself in different ways. So you can treat ``_errors`` as a dictionary
mapping field names to lists.
View
11 docs/releases/1.7.txt
@@ -460,3 +460,14 @@ a bug and has been addressed.
The ``syncdb`` command has been deprecated in favour of the new ``migrate``
command. ``migrate`` takes the same arguments as ``syncdb`` used to plus a few
more, so it's safe to just change the name you're calling and nothing else.
+
+``util`` modules renamed to ``utils``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The following instances of ``util.py`` in the Django codebase have been renamed
+to ``utils.py`` in an effort to unify all util and utils references:
+
+* ``django.contrib.admin.util``
+* ``django.contrib.gis.db.backends.util``
+* ``django.db.backends.util``
+* ``django.forms.util``
View
2  docs/topics/forms/formsets.txt
@@ -215,7 +215,7 @@ this management data, an exception will be raised::
>>> formset = ArticleFormSet(data)
Traceback (most recent call last):
...
- django.forms.util.ValidationError: [u'ManagementForm data is missing or has been tampered with']
+ django.forms.utils.ValidationError: [u'ManagementForm data is missing or has been tampered with']
It is used to keep track of how many form instances are being displayed. If
you are adding new forms via JavaScript, you should increment the count fields
View
2  tests/admin_custom_urls/tests.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
import warnings
-from django.contrib.admin.util import quote
+from django.contrib.admin.utils import quote
from django.core.urlresolvers import reverse
from django.template.response import TemplateResponse
from django.test import TestCase
View
2  tests/admin_util/tests.py
@@ -5,7 +5,7 @@
from django.conf import settings
from django.contrib import admin
from django.contrib.admin import helpers
-from django.contrib.admin.util import (display_for_field, flatten_fieldsets,
+from django.contrib.admin.utils import (display_for_field, flatten_fieldsets,
label_for_field, lookup_field, NestedObjects)
from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
from django.contrib.sites.models import Site
View
2  tests/admin_views/admin.py
@@ -768,7 +768,7 @@ class ChoiceList(admin.ModelAdmin):
# related OneToOne object not registered in admin
# when deleting Book so as exercise all four troublesome (w.r.t escaping
# and calling force_text to avoid problems on Python 2.3) paths through
-# contrib.admin.util's get_deleted_objects function.
+# contrib.admin.utils's get_deleted_objects function.
site.register(Book, inlines=[ChapterInline])
site.register(Promo)
site.register(ChapterXtra1, ChapterXtra1Admin)
View
4 tests/admin_views/tests.py
@@ -15,14 +15,14 @@
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
from django.contrib.admin.models import LogEntry, DELETION
from django.contrib.admin.sites import LOGIN_FORM_KEY
-from django.contrib.admin.util import quote
+from django.contrib.admin.utils import quote
from django.contrib.admin.views.main import IS_POPUP_VAR
from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.models import Group, User, Permission
from django.contrib.contenttypes.models import ContentType
from django.db import connection
-from django.forms.util import ErrorList
+from django.forms.utils import ErrorList
from django.template.response import TemplateResponse
from django.test import TestCase
from django.test.utils import patch_logger
View
2  tests/backends/tests.py
@@ -15,7 +15,7 @@
from django.db.backends.signals import connection_created
from django.db.backends.sqlite3.base import DatabaseOperations
from django.db.backends.postgresql_psycopg2 import version as pg_version
-from django.db.backends.util import format_number
+from django.db.backends.utils import format_number
from django.db.models import Sum, Avg, Variance, StdDev
from django.db.models.fields import (AutoField, DateField, DateTimeField,
DecimalField, IntegerField, TimeField)
View
2  tests/db_typecasts/tests.py
@@ -3,7 +3,7 @@
import datetime
import unittest
-from django.db.backends import util as typecasts
+from django.db.backends import utils as typecasts
from django.utils import six
View
2  tests/forms_tests/tests/test_error_messages.py
@@ -215,7 +215,7 @@ def clean(self):
raise ValidationError("I like to be awkward.")
@python_2_unicode_compatible
- class CustomErrorList(util.ErrorList):
+ class CustomErrorList(utils.ErrorList):
def __str__(self):
return self.as_divs()
View
2  tests/forms_tests/tests/test_extra.py
@@ -5,7 +5,7 @@
from django.forms import *
from django.forms.extras import SelectDateWidget
-from django.forms.util import ErrorList
+from django.forms.utils import ErrorList
from django.test import TestCase
from django.test.utils import override_settings
from django.utils import six
View
6 tests/forms_tests/tests/test_fields.py
@@ -1142,7 +1142,7 @@ def test_filepathfield_2(self):
('/django/forms/forms.py', 'forms.py'),
('/django/forms/formsets.py', 'formsets.py'),
('/django/forms/models.py', 'models.py'),
- ('/django/forms/util.py', 'util.py'),
+ ('/django/forms/utils.py', 'utils.py'),
('/django/forms/widgets.py', 'widgets.py')
]
for exp, got in zip(expected, fix_os_paths(f.choices)):
@@ -1162,7 +1162,7 @@ def test_filepathfield_3(self):
('/django/forms/forms.py', 'forms.py'),
('/django/forms/formsets.py', 'formsets.py'),
('/django/forms/models.py', 'models.py'),
- ('/django/forms/util.py', 'util.py'),
+ ('/django/forms/utils.py', 'utils.py'),
('/django/forms/widgets.py', 'widgets.py')
]
for exp, got in zip(expected, fix_os_paths(f.choices)):
@@ -1182,7 +1182,7 @@ def test_filepathfield_4(self):
('/django/forms/forms.py', 'forms.py'),
('/django/forms/formsets.py', 'formsets.py'),
('/django/forms/models.py', 'models.py'),
- ('/django/forms/util.py', 'util.py'),
+ ('/django/forms/utils.py', 'utils.py'),
('/django/forms/widgets.py', 'widgets.py')
]
for exp, got in zip(expected, fix_os_paths(f.choices)):
View
2  tests/forms_tests/tests/test_formsets.py
@@ -6,7 +6,7 @@
from django.forms import (CharField, DateField, FileField, Form, IntegerField,
SplitDateTimeField, ValidationError, formsets)
from django.forms.formsets import BaseFormSet, formset_factory
-from django.forms.util import ErrorList
+from django.forms.utils import ErrorList
from django.test import TestCase
View
4 tests/forms_tests/tests/test_util.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
from django.core.exceptions import ValidationError
-from django.forms.util import flatatt, ErrorDict, ErrorList
+from django.forms.utils import flatatt, ErrorDict, ErrorList
from django.test import TestCase
from django.utils.safestring import mark_safe
from django.utils import six
@@ -11,7 +11,7 @@
class FormsUtilTestCase(TestCase):
- # Tests for forms/util.py module.
+ # Tests for forms/utils.py module.
def test_flatatt(self):
###########
View
2  tests/model_formsets_regress/tests.py
@@ -2,7 +2,7 @@
from django import forms
from django.forms.formsets import BaseFormSet, DELETION_FIELD_NAME
-from django.forms.util import ErrorDict, ErrorList
+from django.forms.utils import ErrorDict, ErrorList
from django.forms.models import modelform_factory, inlineformset_factory, modelformset_factory, BaseModelFormSet
from django.test import TestCase
from django.utils import six
View
2  tests/proxy_models/tests.py
@@ -382,7 +382,7 @@ def test_cascade_delete_proxy_model_admin_warning(self):
base_user = BaseUser.objects.all()[0]
issue = Issue.objects.all()[0]
with self.assertNumQueries(7):
- collector = admin.util.NestedObjects('default')
+ collector = admin.utils.NestedObjects('default')
collector.collect(ProxyTrackerUser.objects.all())
self.assertTrue(tracker_user in collector.edges.get(None, ()))
self.assertTrue(base_user in collector.edges.get(None, ()))

1 comment on commit 18ffdb1

@jezdez
Owner

@timgraham You're quickly becoming my favorite core dev!

Please sign in to comment.
Something went wrong with that request. Please try again.