From 46a3d7604e7fecde8df02ec363200ec5e0ce894e Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 10 Oct 2016 10:13:01 -0400 Subject: [PATCH] Fixed gis_tests.geoapp when run in isolation. "from django.db.models import *" in contrib/gis/db/models/__init__.py could obscure gis's functions.py resulting in exceptions like: "module 'django.db.models.functions' has no attribute 'Union'". --- django/contrib/gis/db/models/__init__.py | 13 ++++++-- django/db/models/__init__.py | 38 +++++++++++++++++------- django/db/models/indexes.py | 2 +- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/django/contrib/gis/db/models/__init__.py b/django/contrib/gis/db/models/__init__.py index c2025b05a1..84f84d32b0 100644 --- a/django/contrib/gis/db/models/__init__.py +++ b/django/contrib/gis/db/models/__init__.py @@ -1,8 +1,17 @@ from django.db.models import * # NOQA isort:skip +from django.db.models import __all__ as models_all # isort:skip from django.contrib.gis.db.models.aggregates import * # NOQA -from django.contrib.gis.db.models.fields import ( # NOQA +from django.contrib.gis.db.models.aggregates import __all__ as aggregates_all +from django.contrib.gis.db.models.fields import ( GeometryCollectionField, GeometryField, LineStringField, MultiLineStringField, MultiPointField, MultiPolygonField, PointField, PolygonField, RasterField, ) -from django.contrib.gis.db.models.manager import GeoManager # NOQA +from django.contrib.gis.db.models.manager import GeoManager + +__all__ = models_all + aggregates_all +__all__ += [ + 'GeometryCollectionField', 'GeometryField', 'LineStringField', + 'MultiLineStringField', 'MultiPointField', 'MultiPolygonField', 'PointField', + 'PolygonField', 'RasterField', 'GeoManager', +] diff --git a/django/db/models/__init__.py b/django/db/models/__init__.py index 3ea2891675..225436231c 100644 --- a/django/db/models/__init__.py +++ b/django/db/models/__init__.py @@ -1,25 +1,28 @@ -from django.core.exceptions import ObjectDoesNotExist # NOQA -from django.db.models import signals # NOQA +from django.core.exceptions import ObjectDoesNotExist +from django.db.models import signals from django.db.models.aggregates import * # NOQA -from django.db.models.deletion import ( # NOQA +from django.db.models.aggregates import __all__ as aggregates_all +from django.db.models.deletion import ( CASCADE, DO_NOTHING, PROTECT, SET, SET_DEFAULT, SET_NULL, ProtectedError, ) -from django.db.models.expressions import ( # NOQA +from django.db.models.expressions import ( Case, Expression, ExpressionWrapper, F, Func, Value, When, ) from django.db.models.fields import * # NOQA -from django.db.models.fields.files import FileField, ImageField # NOQA -from django.db.models.fields.proxy import OrderWrt # NOQA +from django.db.models.fields import __all__ as fields_all +from django.db.models.fields.files import FileField, ImageField +from django.db.models.fields.proxy import OrderWrt from django.db.models.indexes import * # NOQA -from django.db.models.lookups import Lookup, Transform # NOQA -from django.db.models.manager import Manager # NOQA -from django.db.models.query import ( # NOQA +from django.db.models.indexes import __all__ as indexes_all +from django.db.models.lookups import Lookup, Transform +from django.db.models.manager import Manager +from django.db.models.query import ( Prefetch, Q, QuerySet, prefetch_related_objects, ) # Imports that would create circular imports if sorted -from django.db.models.base import DEFERRED, Model # NOQA isort:skip -from django.db.models.fields.related import ( # NOQA isort:skip +from django.db.models.base import DEFERRED, Model # isort:skip +from django.db.models.fields.related import ( # isort:skip ForeignKey, ForeignObject, OneToOneField, ManyToManyField, ManyToOneRel, ManyToManyRel, OneToOneRel, ) @@ -52,3 +55,16 @@ def permalink(func): bits = func(*args, **kwargs) return reverse(bits[0], None, *bits[1:3]) return inner + + +__all__ = aggregates_all + fields_all + indexes_all +__all__ += [ + 'ObjectDoesNotExist', 'signals', + 'CASCADE', 'DO_NOTHING', 'PROTECT', 'SET', 'SET_DEFAULT', 'SET_NULL', + 'ProtectedError', + 'Case', 'Expression', 'ExpressionWrapper', 'F', 'Func', 'Value', 'When', + 'FileField', 'ImageField', 'OrderWrt', 'Lookup', 'Transform', 'Manager', + 'Prefetch', 'Q', 'QuerySet', 'prefetch_related_objects', 'DEFERRED', 'Model', + 'ForeignKey', 'ForeignObject', 'OneToOneField', 'ManyToManyField', + 'ManyToOneRel', 'ManyToManyRel', 'OneToOneRel', 'permalink', +] diff --git a/django/db/models/indexes.py b/django/db/models/indexes.py index 2396ba2819..c1ce0b90e7 100644 --- a/django/db/models/indexes.py +++ b/django/db/models/indexes.py @@ -4,7 +4,7 @@ import hashlib from django.utils.encoding import force_bytes -__all__ = ['Index'] +__all__ = [str('Index')] # The max length of the names of the indexes (restricted to 30 due to Oracle) MAX_NAME_LENGTH = 30