diff --git a/django/bin/profiling/gather_profile_stats.py b/django/bin/profiling/gather_profile_stats.py
index 0fd2b7f..2274ead 100644
--- a/django/bin/profiling/gather_profile_stats.py
+++ b/django/bin/profiling/gather_profile_stats.py
@@ -8,8 +8,9 @@ hotshot.stats (the formats are incompatible)
 """
 
 from hotshot import stats
+import os
 import pstats
-import sys, os
+import sys
 
 def gather_stats(p):
     profiles = {}
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
index c74657a..e07414b 100644
--- a/django/contrib/admin/templatetags/admin_list.py
+++ b/django/contrib/admin/templatetags/admin_list.py
@@ -3,11 +3,10 @@ import datetime
 from django.conf import settings
 from django.contrib.admin.util import lookup_field, display_for_field, label_for_field
 from django.contrib.admin.views.main import (ALL_VAR, EMPTY_CHANGELIST_VALUE,
-    ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR)
+    ORDER_VAR, PAGE_VAR, SEARCH_VAR)
 from django.core.exceptions import ObjectDoesNotExist
 from django.db import models
 from django.utils import formats
-from django.utils.datastructures import SortedDict
 from django.utils.html import escape, conditional_escape
 from django.utils.safestring import mark_safe
 from django.utils.text import capfirst
diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
index aea656f..d7adc48 100644
--- a/django/contrib/admin/views/main.py
+++ b/django/contrib/admin/views/main.py
@@ -19,15 +19,13 @@ MAX_SHOW_ALL_ALLOWED = 200
 # Changelist settings
 ALL_VAR = 'all'
 ORDER_VAR = 'o'
-ORDER_TYPE_VAR = 'ot'
 PAGE_VAR = 'p'
 SEARCH_VAR = 'q'
 TO_FIELD_VAR = 't'
 IS_POPUP_VAR = 'pop'
 ERROR_FLAG = 'e'
 
-IGNORED_PARAMS = (
-    ALL_VAR, ORDER_VAR, ORDER_TYPE_VAR, SEARCH_VAR, IS_POPUP_VAR, TO_FIELD_VAR)
+IGNORED_PARAMS = (ALL_VAR, ORDER_VAR, SEARCH_VAR, IS_POPUP_VAR, TO_FIELD_VAR)
 
 # Text to display within change-list table cells if the value is blank.
 EMPTY_CHANGELIST_VALUE = ugettext_lazy('(None)')
diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py
index 319b489..a1d6b9b 100644
--- a/django/contrib/admindocs/views.py
+++ b/django/contrib/admindocs/views.py
@@ -1,4 +1,8 @@
-from django import template, templatetags
+import inspect
+import os
+import re
+
+from django import template
 from django.template import RequestContext
 from django.conf import settings
 from django.contrib.admin.views.decorators import staff_member_required
@@ -12,7 +16,6 @@ from django.contrib.sites.models import Site
 from django.utils.importlib import import_module
 from django.utils.translation import ugettext as _
 from django.utils.safestring import mark_safe
-import inspect, os, re
 
 # Exclude methods starting with these strings from documentation
 MODEL_METHODS_EXCLUDE = ('_', 'add_', 'delete', 'save', 'set_')
diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py
index f11f830..141cac7 100644
--- a/django/contrib/auth/__init__.py
+++ b/django/contrib/auth/__init__.py
@@ -1,4 +1,3 @@
-import datetime
 from warnings import warn
 from django.core.exceptions import ImproperlyConfigured
 from django.utils.importlib import import_module
diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py
index d8c8140..fc751c7 100644
--- a/django/contrib/auth/backends.py
+++ b/django/contrib/auth/backends.py
@@ -1,4 +1,3 @@
-from django.db import connection
 from django.contrib.auth.models import User, Permission
 
 
diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py
index 9966849..f82060e 100644
--- a/django/contrib/auth/management/__init__.py
+++ b/django/contrib/auth/management/__init__.py
@@ -102,8 +102,8 @@ def get_default_username(check_db=True):
     :returns: The username, or an empty string if no username can be
         determined.
     """
-    from django.contrib.auth.management.commands.createsuperuser import \
-        RE_VALID_USERNAME
+    from django.contrib.auth.management.commands.createsuperuser import (
+        RE_VALID_USERNAME)
     default_username = get_system_username()
     try:
         default_username = unicodedata.normalize('NFKD', default_username)\
diff --git a/django/contrib/auth/tests/auth_backends.py b/django/contrib/auth/tests/auth_backends.py
index 63b65ad..5163943 100644
--- a/django/contrib/auth/tests/auth_backends.py
+++ b/django/contrib/auth/tests/auth_backends.py
@@ -1,5 +1,3 @@
-import warnings
-
 from django.conf import settings
 from django.contrib.auth.models import User, Group, Permission, AnonymousUser
 from django.contrib.contenttypes.models import ContentType
diff --git a/django/contrib/auth/tests/tokens.py b/django/contrib/auth/tests/tokens.py
index 9211e06..f7fc32e 100644
--- a/django/contrib/auth/tests/tokens.py
+++ b/django/contrib/auth/tests/tokens.py
@@ -1,7 +1,7 @@
 from datetime import date, timedelta
 
 from django.conf import settings
-from django.contrib.auth.models import User, AnonymousUser
+from django.contrib.auth.models import User
 from django.contrib.auth.tokens import PasswordResetTokenGenerator
 from django.test import TestCase
 
diff --git a/django/contrib/formtools/preview.py b/django/contrib/formtools/preview.py
index b4cdeba..d2e6987 100644
--- a/django/contrib/formtools/preview.py
+++ b/django/contrib/formtools/preview.py
@@ -2,12 +2,6 @@
 Formtools Preview application.
 """
 
-try:
-    import cPickle as pickle
-except ImportError:
-    import pickle
-
-from django.conf import settings
 from django.http import Http404
 from django.shortcuts import render_to_response
 from django.template.context import RequestContext
diff --git a/django/contrib/formtools/utils.py b/django/contrib/formtools/utils.py
index 4489506..3c0f7db 100644
--- a/django/contrib/formtools/utils.py
+++ b/django/contrib/formtools/utils.py
@@ -5,7 +5,6 @@ except ImportError:
 
 import hashlib
 from django.conf import settings
-from django.forms import BooleanField
 from django.utils.crypto import salted_hmac
 
 
diff --git a/django/contrib/formtools/wizard/storage/session.py b/django/contrib/formtools/wizard/storage/session.py
index 84a3848..9cfae50 100644
--- a/django/contrib/formtools/wizard/storage/session.py
+++ b/django/contrib/formtools/wizard/storage/session.py
@@ -1,4 +1,3 @@
-from django.core.files.uploadedfile import UploadedFile
 from django.contrib.formtools.wizard import storage
 
 
diff --git a/django/contrib/formtools/wizard/views.py b/django/contrib/formtools/wizard/views.py
index ac9cfbd..925e16f 100644
--- a/django/contrib/formtools/wizard/views.py
+++ b/django/contrib/formtools/wizard/views.py
@@ -1,4 +1,3 @@
-import copy
 import re
 
 from django import forms
diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py
index 8e1faf2..1014cb3 100644
--- a/django/contrib/gis/admin/options.py
+++ b/django/contrib/gis/admin/options.py
@@ -1,4 +1,3 @@
-from django.conf import settings
 from django.contrib.admin import ModelAdmin
 from django.contrib.gis.admin.widgets import OpenLayersWidget
 from django.contrib.gis.gdal import OGRGeomType
diff --git a/django/contrib/gis/db/backends/base.py b/django/contrib/gis/db/backends/base.py
index 0eaacae..2a62d97 100644
--- a/django/contrib/gis/db/backends/base.py
+++ b/django/contrib/gis/db/backends/base.py
@@ -3,7 +3,6 @@ Base/mixin classes for the spatial backend database operations and the
 `SpatialRefSys` model the backend.
 """
 import re
-from django.conf import settings
 from django.contrib.gis import gdal
 
 class BaseSpatialOperations(object):
diff --git a/django/contrib/gis/db/backends/oracle/models.py b/django/contrib/gis/db/backends/oracle/models.py
index de757ff..ed29f7b 100644
--- a/django/contrib/gis/db/backends/oracle/models.py
+++ b/django/contrib/gis/db/backends/oracle/models.py
@@ -8,7 +8,6 @@
  model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model.
 """
 from django.contrib.gis.db import models
-from django.contrib.gis.db.models.fields import GeometryField
 from django.contrib.gis.db.backends.base import SpatialRefSysMixin
 
 class GeometryColumns(models.Model):
diff --git a/django/contrib/gis/db/backends/spatialite/base.py b/django/contrib/gis/db/backends/spatialite/base.py
index 729fc15..50467fc 100644
--- a/django/contrib/gis/db/backends/spatialite/base.py
+++ b/django/contrib/gis/db/backends/spatialite/base.py
@@ -3,8 +3,8 @@ from django.conf import settings
 
 from django.core.exceptions import ImproperlyConfigured
 from django.db.backends.sqlite3.base import *
-from django.db.backends.sqlite3.base import DatabaseWrapper as SqliteDatabaseWrapper, \
-    _sqlite_extract, _sqlite_date_trunc, _sqlite_regexp
+from django.db.backends.sqlite3.base import DatabaseWrapper as SqliteDatabaseWrapper
+from django.db.backends.sqlite3.base import _sqlite_extract, _sqlite_date_trunc, _sqlite_regexp
 from django.contrib.gis.db.backends.spatialite.client import SpatiaLiteClient
 from django.contrib.gis.db.backends.spatialite.creation import SpatiaLiteCreation
 from django.contrib.gis.db.backends.spatialite.introspection import SpatiaLiteIntrospection
diff --git a/django/contrib/gis/db/models/__init__.py b/django/contrib/gis/db/models/__init__.py
index 87e2b68..e36aa36 100644
--- a/django/contrib/gis/db/models/__init__.py
+++ b/django/contrib/gis/db/models/__init__.py
@@ -8,7 +8,7 @@ from django.contrib.gis.db.models.aggregates import *
 from django.contrib.gis.db.models.manager import GeoManager
 
 # The geographic-enabled fields.
-from django.contrib.gis.db.models.fields import \
-     GeometryField, PointField, LineStringField, PolygonField, \
-     MultiPointField, MultiLineStringField, MultiPolygonField, \
-     GeometryCollectionField
+from django.contrib.gis.db.models.fields import (
+     GeometryField, PointField, LineStringField, PolygonField,
+     MultiPointField, MultiLineStringField, MultiPolygonField,
+     GeometryCollectionField)
diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py
index 4df1a3a..c1e360d 100644
--- a/django/contrib/gis/db/models/query.py
+++ b/django/contrib/gis/db/models/query.py
@@ -1,9 +1,9 @@
 from django.db import connections
-from django.db.models.query import QuerySet, Q, ValuesQuerySet, ValuesListQuerySet
+from django.db.models.query import QuerySet, ValuesQuerySet, ValuesListQuerySet
 
 from django.contrib.gis.db.models import aggregates
-from django.contrib.gis.db.models.fields import get_srid_info, GeometryField, PointField, LineStringField
-from django.contrib.gis.db.models.sql import AreaField, DistanceField, GeomField, GeoQuery, GeoWhereNode
+from django.contrib.gis.db.models.fields import get_srid_info, PointField, LineStringField
+from django.contrib.gis.db.models.sql import AreaField, DistanceField, GeomField, GeoQuery
 from django.contrib.gis.geometry.backend import Geometry
 from django.contrib.gis.measure import Area, Distance
 
diff --git a/django/contrib/gis/db/models/sql/aggregates.py b/django/contrib/gis/db/models/sql/aggregates.py
index fed2a2e..9fcbb51 100644
--- a/django/contrib/gis/db/models/sql/aggregates.py
+++ b/django/contrib/gis/db/models/sql/aggregates.py
@@ -1,6 +1,5 @@
 from django.db.models.sql.aggregates import *
 from django.contrib.gis.db.models.fields import GeometryField
-from django.contrib.gis.db.models.sql.conversion import GeomField
 
 class GeoAggregate(Aggregate):
     # Default SQL template for spatial aggregates.
diff --git a/django/contrib/gis/db/models/sql/where.py b/django/contrib/gis/db/models/sql/where.py
index 17c210b..0e15222 100644
--- a/django/contrib/gis/db/models/sql/where.py
+++ b/django/contrib/gis/db/models/sql/where.py
@@ -1,4 +1,4 @@
-from django.db.models.fields import Field, FieldDoesNotExist
+from django.db.models.fields import FieldDoesNotExist
 from django.db.models.sql.constants import LOOKUP_SEP
 from django.db.models.sql.expressions import SQLEvaluator
 from django.db.models.sql.where import Constraint, WhereNode
diff --git a/django/contrib/gis/feeds.py b/django/contrib/gis/feeds.py
index 4105ef7..c080352 100644
--- a/django/contrib/gis/feeds.py
+++ b/django/contrib/gis/feeds.py
@@ -1,4 +1,4 @@
-from django.contrib.syndication.feeds import Feed as BaseFeed, FeedDoesNotExist
+from django.contrib.syndication.feeds import Feed as BaseFeed
 from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
 
 class GeoFeedMixin(object):
diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py
index 7db5fd9..e5f3602 100644
--- a/django/contrib/gis/gdal/datasource.py
+++ b/django/contrib/gis/gdal/datasource.py
@@ -34,7 +34,7 @@
               val = field.value
 """
 # ctypes prerequisites.
-from ctypes import byref, c_void_p
+from ctypes import byref
 
 # The GDAL C library, OGR exceptions, and the Layer object.
 from django.contrib.gis.gdal.base import GDALBase
diff --git a/django/contrib/gis/gdal/feature.py b/django/contrib/gis/gdal/feature.py
index b5c173a..47fd9e5 100644
--- a/django/contrib/gis/gdal/feature.py
+++ b/django/contrib/gis/gdal/feature.py
@@ -3,7 +3,6 @@ from django.contrib.gis.gdal.base import GDALBase
 from django.contrib.gis.gdal.error import OGRException, OGRIndexError
 from django.contrib.gis.gdal.field import Field
 from django.contrib.gis.gdal.geometries import OGRGeometry, OGRGeomType
-from django.contrib.gis.gdal.srs import SpatialReference
 
 # ctypes function prototypes
 from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api
diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py
index 256ddb2..d904327 100644
--- a/django/contrib/gis/gdal/libgdal.py
+++ b/django/contrib/gis/gdal/libgdal.py
@@ -1,4 +1,5 @@
-import os, re, sys
+import os
+import re
 from ctypes import c_char_p, CDLL
 from ctypes.util import find_library
 from django.contrib.gis.gdal.error import OGRException
diff --git a/django/contrib/gis/gdal/prototypes/ds.py b/django/contrib/gis/gdal/prototypes/ds.py
index 44828ee..d8537bc 100644
--- a/django/contrib/gis/gdal/prototypes/ds.py
+++ b/django/contrib/gis/gdal/prototypes/ds.py
@@ -6,9 +6,8 @@
 from ctypes import c_char_p, c_double, c_int, c_long, c_void_p, POINTER
 from django.contrib.gis.gdal.envelope import OGREnvelope
 from django.contrib.gis.gdal.libgdal import lgdal
-from django.contrib.gis.gdal.prototypes.generation import \
-    const_string_output, double_output, geom_output, int_output, \
-    srs_output, void_output, voidptr_output
+from django.contrib.gis.gdal.prototypes.generation import (const_string_output,
+    double_output, geom_output, int_output, srs_output, void_output, voidptr_output)
 
 c_int_p = POINTER(c_int) # shortcut type
 
diff --git a/django/contrib/gis/gdal/prototypes/generation.py b/django/contrib/gis/gdal/prototypes/generation.py
index 1303532..45cffd6 100644
--- a/django/contrib/gis/gdal/prototypes/generation.py
+++ b/django/contrib/gis/gdal/prototypes/generation.py
@@ -4,9 +4,9 @@
 """
 
 from ctypes import c_char_p, c_double, c_int, c_void_p
-from django.contrib.gis.gdal.prototypes.errcheck import \
-    check_arg_errcode, check_errcode, check_geom, check_geom_offset, \
-    check_pointer, check_srs, check_str_arg, check_string, check_const_string
+from django.contrib.gis.gdal.prototypes.errcheck import (
+    check_arg_errcode, check_errcode, check_geom, check_geom_offset,
+    check_pointer, check_srs, check_str_arg, check_string, check_const_string)
 
 class gdal_char_p(c_char_p):
     pass
diff --git a/django/contrib/gis/gdal/prototypes/geom.py b/django/contrib/gis/gdal/prototypes/geom.py
index e002590..7fa8391 100644
--- a/django/contrib/gis/gdal/prototypes/geom.py
+++ b/django/contrib/gis/gdal/prototypes/geom.py
@@ -1,12 +1,9 @@
-import re
-from datetime import date
-from ctypes import c_char, c_char_p, c_double, c_int, c_ubyte, c_void_p, POINTER
+from ctypes import c_char_p, c_double, c_int, c_void_p, POINTER
 from django.contrib.gis.gdal.envelope import OGREnvelope
 from django.contrib.gis.gdal.libgdal import lgdal, GEOJSON
 from django.contrib.gis.gdal.prototypes.errcheck import check_bool, check_envelope
-from django.contrib.gis.gdal.prototypes.generation import \
-    const_string_output, double_output, geom_output, int_output, \
-    srs_output, string_output, void_output
+from django.contrib.gis.gdal.prototypes.generation import (const_string_output,
+    double_output, geom_output, int_output, srs_output, string_output, void_output)
 
 ### Generation routines specific to this module ###
 def env_func(f, argtypes):
diff --git a/django/contrib/gis/gdal/prototypes/srs.py b/django/contrib/gis/gdal/prototypes/srs.py
index 411cec9..66cf84c 100644
--- a/django/contrib/gis/gdal/prototypes/srs.py
+++ b/django/contrib/gis/gdal/prototypes/srs.py
@@ -1,8 +1,7 @@
 from ctypes import c_char_p, c_int, c_void_p, POINTER
 from django.contrib.gis.gdal.libgdal import lgdal, std_call
-from django.contrib.gis.gdal.prototypes.generation import \
-    const_string_output, double_output, int_output, \
-    srs_output, string_output, void_output
+from django.contrib.gis.gdal.prototypes.generation import (const_string_output,
+    double_output, int_output, srs_output, string_output, void_output)
 
 ## Shortcut generation for routines with known parameters.
 def srs_double(f):
diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py
index 95e71f1..e211bac 100644
--- a/django/contrib/gis/gdal/srs.py
+++ b/django/contrib/gis/gdal/srs.py
@@ -26,12 +26,11 @@
   >>> print srs.name
   NAD83 / Texas South Central
 """
-import re
-from ctypes import byref, c_char_p, c_int, c_void_p
+from ctypes import byref, c_char_p, c_int
 
 # Getting the error checking routine and exceptions
 from django.contrib.gis.gdal.base import GDALBase
-from django.contrib.gis.gdal.error import OGRException, SRSException
+from django.contrib.gis.gdal.error import SRSException
 from django.contrib.gis.gdal.prototypes import srs as capi
 
 #### Spatial Reference class. ####
diff --git a/django/contrib/gis/gdal/tests/test_driver.py b/django/contrib/gis/gdal/tests/test_driver.py
index 1ff65ac..06ec93f 100644
--- a/django/contrib/gis/gdal/tests/test_driver.py
+++ b/django/contrib/gis/gdal/tests/test_driver.py
@@ -1,4 +1,4 @@
-import os, os.path, unittest
+import unittest
 from django.contrib.gis.gdal import Driver, OGRException
 
 valid_drivers = ('ESRI Shapefile', 'MapInfo File', 'TIGER', 'S57', 'DGN',
diff --git a/django/contrib/gis/gdal/tests/test_geom.py b/django/contrib/gis/gdal/tests/test_geom.py
index 7d4a1ff..5703a09 100644
--- a/django/contrib/gis/gdal/tests/test_geom.py
+++ b/django/contrib/gis/gdal/tests/test_geom.py
@@ -1,6 +1,5 @@
-from django.contrib.gis.gdal import OGRGeometry, OGRGeomType, \
-    OGRException, OGRIndexError, SpatialReference, CoordTransform, \
-    GDAL_VERSION
+from django.contrib.gis.gdal import (OGRGeometry, OGRGeomType, OGRException,
+    OGRIndexError, SpatialReference, CoordTransform, GDAL_VERSION)
 from django.utils import unittest
 from django.contrib.gis.geometry.test_data import TestDataMixin
 
@@ -446,9 +445,12 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
 
     def test17_pickle(self):
         "Testing pickle support."
-        import cPickle
+        try:
+            import cPickle as pickle
+        except ImportError:
+            import pickle
         g1 = OGRGeometry('LINESTRING(1 1 1,2 2 2,3 3 3)', 'WGS84')
-        g2 = cPickle.loads(cPickle.dumps(g1))
+        g2 = pickle.loads(pickle.dumps(g1))
         self.assertEqual(g1, g2)
         self.assertEqual(4326, g2.srs.srid)
         self.assertEqual(g1.srs.wkt, g2.srs.wkt)
diff --git a/django/contrib/gis/geometry/backend/geos.py b/django/contrib/gis/geometry/backend/geos.py
index a1ac096..cdc40ed 100644
--- a/django/contrib/gis/geometry/backend/geos.py
+++ b/django/contrib/gis/geometry/backend/geos.py
@@ -1,3 +1,2 @@
-from django.contrib.gis.geos import \
-    GEOSGeometry as Geometry, \
-    GEOSException as GeometryException
+from django.contrib.gis.geos import (
+    GEOSGeometry as Geometry, GEOSException as GeometryException)
diff --git a/django/contrib/gis/geos/base.py b/django/contrib/gis/geos/base.py
index 34c03c8..b3012dd 100644
--- a/django/contrib/gis/geos/base.py
+++ b/django/contrib/gis/geos/base.py
@@ -1,6 +1,6 @@
 from ctypes import c_void_p
 from types import NoneType
-from django.contrib.gis.geos.error import GEOSException, GEOSIndexError
+from django.contrib.gis.geos.error import GEOSException
 
 # Trying to import GDAL libraries, if available.  Have to place in
 # try/except since this package may be used outside GeoDjango.
diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py
index 515f80e..8b0edf5 100644
--- a/django/contrib/gis/geos/collections.py
+++ b/django/contrib/gis/geos/collections.py
@@ -3,9 +3,9 @@
  GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
 """
 from ctypes import c_int, c_uint, byref
-from django.contrib.gis.geos.error import GEOSException, GEOSIndexError
+from django.contrib.gis.geos.error import GEOSException
 from django.contrib.gis.geos.geometry import GEOSGeometry
-from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOM_PTR, GEOS_PREPARE
+from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOS_PREPARE
 from django.contrib.gis.geos.linestring import LineString, LinearRing
 from django.contrib.gis.geos.point import Point
 from django.contrib.gis.geos.polygon import Polygon
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index a9d1264..c56eeb3 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -3,9 +3,8 @@
  inherit from this object.
 """
 # Python, ctypes and types dependencies.
-import re
 import warnings
-from ctypes import addressof, byref, c_double, c_size_t
+from ctypes import addressof, byref, c_double
 
 # super-class for mutable list behavior
 from django.contrib.gis.geos.mutable_list import ListMixin
diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
index 7e1dfa0..e73fcdb 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -6,7 +6,9 @@
  This module also houses GEOS Pointer utilities, including
  get_pointer_arr(), and GEOM_PTR.
 """
-import os, re, sys
+import os
+import re
+import sys
 from ctypes import c_char_p, Structure, CDLL, CFUNCTYPE, POINTER
 from ctypes.util import find_library
 from django.contrib.gis.geos.error import GEOSException
diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py
index 92b2e4c..77ce60c 100644
--- a/django/contrib/gis/geos/polygon.py
+++ b/django/contrib/gis/geos/polygon.py
@@ -1,5 +1,4 @@
 from ctypes import c_uint, byref
-from django.contrib.gis.geos.error import GEOSIndexError
 from django.contrib.gis.geos.geometry import GEOSGeometry
 from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOM_PTR
 from django.contrib.gis.geos.linestring import LinearRing
diff --git a/django/contrib/gis/geos/prototypes/__init__.py b/django/contrib/gis/geos/prototypes/__init__.py
index 23735f5..89b96c0 100644
--- a/django/contrib/gis/geos/prototypes/__init__.py
+++ b/django/contrib/gis/geos/prototypes/__init__.py
@@ -5,26 +5,26 @@
 """
 
 # Coordinate sequence routines.
-from django.contrib.gis.geos.prototypes.coordseq import create_cs, get_cs, \
-    cs_clone, cs_getordinate, cs_setordinate, cs_getx, cs_gety, cs_getz, \
-    cs_setx, cs_sety, cs_setz, cs_getsize, cs_getdims
+from django.contrib.gis.geos.prototypes.coordseq import (create_cs, get_cs,
+    cs_clone, cs_getordinate, cs_setordinate, cs_getx, cs_gety, cs_getz,
+    cs_setx, cs_sety, cs_setz, cs_getsize, cs_getdims)
 
 # Geometry routines.
-from django.contrib.gis.geos.prototypes.geom import from_hex, from_wkb, from_wkt, \
-    create_point, create_linestring, create_linearring, create_polygon, create_collection, \
-    destroy_geom, get_extring, get_intring, get_nrings, get_geomn, geom_clone, \
-    geos_normalize, geos_type, geos_typeid, geos_get_srid, geos_set_srid, \
-    get_dims, get_num_coords, get_num_geoms, \
-    to_hex, to_wkb, to_wkt
+from django.contrib.gis.geos.prototypes.geom import (from_hex, from_wkb, from_wkt,
+    create_point, create_linestring, create_linearring, create_polygon, create_collection,
+    destroy_geom, get_extring, get_intring, get_nrings, get_geomn, geom_clone,
+    geos_normalize, geos_type, geos_typeid, geos_get_srid, geos_set_srid,
+    get_dims, get_num_coords, get_num_geoms,
+    to_hex, to_wkb, to_wkt)
 
 # Miscellaneous routines.
 from django.contrib.gis.geos.prototypes.misc import *
 
 # Predicates
-from django.contrib.gis.geos.prototypes.predicates import geos_hasz, geos_isempty, \
-    geos_isring, geos_issimple, geos_isvalid, geos_contains, geos_crosses, \
-    geos_disjoint, geos_equals, geos_equalsexact, geos_intersects, \
-    geos_intersects, geos_overlaps, geos_relatepattern, geos_touches, geos_within
+from django.contrib.gis.geos.prototypes.predicates import (geos_hasz, geos_isempty,
+    geos_isring, geos_issimple, geos_isvalid, geos_contains, geos_crosses,
+    geos_disjoint, geos_equals, geos_equalsexact, geos_intersects,
+    geos_intersects, geos_overlaps, geos_relatepattern, geos_touches, geos_within)
 
 # Topology routines
 from django.contrib.gis.geos.prototypes.topology import *
diff --git a/django/contrib/gis/geos/prototypes/geom.py b/django/contrib/gis/geos/prototypes/geom.py
index 03f9897..5a614fe 100644
--- a/django/contrib/gis/geos/prototypes/geom.py
+++ b/django/contrib/gis/geos/prototypes/geom.py
@@ -1,7 +1,7 @@
-from ctypes import c_char_p, c_int, c_size_t, c_ubyte, c_uint, POINTER
-from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR, PREPGEOM_PTR, GEOS_PREPARE
-from django.contrib.gis.geos.prototypes.errcheck import \
-    check_geom, check_minus_one, check_sized_string, check_string, check_zero
+from ctypes import c_char_p, c_int, c_size_t, c_ubyte, POINTER
+from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR
+from django.contrib.gis.geos.prototypes.errcheck import (
+    check_geom, check_minus_one, check_sized_string, check_string, check_zero)
 from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
 
 # This is the return type used by binary output (WKB, HEX) routines.
diff --git a/django/contrib/gis/geos/prototypes/topology.py b/django/contrib/gis/geos/prototypes/topology.py
index 50817f9..cc5734b 100644
--- a/django/contrib/gis/geos/prototypes/topology.py
+++ b/django/contrib/gis/geos/prototypes/topology.py
@@ -7,7 +7,7 @@ __all__ = ['geos_boundary', 'geos_buffer', 'geos_centroid', 'geos_convexhull',
            'geos_linemerge', 'geos_pointonsurface', 'geos_preservesimplify',
            'geos_simplify', 'geos_symdifference', 'geos_union', 'geos_relate']
 
-from ctypes import c_char_p, c_double, c_int
+from ctypes import c_double, c_int
 from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOS_PREPARE
 from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string
 from django.contrib.gis.geos.prototypes.geom import geos_char_p
diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py
index 4620a9f..f611dd4 100644
--- a/django/contrib/gis/geos/tests/test_geos.py
+++ b/django/contrib/gis/geos/tests/test_geos.py
@@ -1,4 +1,6 @@
-import ctypes, random, unittest, sys
+import ctypes
+import random
+import unittest
 from django.contrib.gis.geos import *
 from django.contrib.gis.geos.base import gdal, numpy, GEOSBase
 from django.contrib.gis.geos.libgeos import GEOS_PREPARE
diff --git a/django/contrib/gis/geos/tests/test_geos_mutation.py b/django/contrib/gis/geos/tests/test_geos_mutation.py
index c8f7e65..0c69b2b 100644
--- a/django/contrib/gis/geos/tests/test_geos_mutation.py
+++ b/django/contrib/gis/geos/tests/test_geos_mutation.py
@@ -2,7 +2,6 @@
 # Modified from original contribution by Aryeh Leib Taurog, which was
 # released under the New BSD license.
 
-import copy
 from django.contrib.gis.geos import *
 from django.contrib.gis.geos.error import GEOSIndexError
 from django.utils import unittest
diff --git a/django/contrib/gis/geos/tests/test_io.py b/django/contrib/gis/geos/tests/test_io.py
index cc0f1ed..50c3668 100644
--- a/django/contrib/gis/geos/tests/test_io.py
+++ b/django/contrib/gis/geos/tests/test_io.py
@@ -1,4 +1,5 @@
-import binascii, ctypes, unittest
+import binascii
+import unittest
 from django.contrib.gis.geos import GEOSGeometry, WKTReader, WKTWriter, WKBReader, WKBWriter, geos_version_info
 
 class GEOSIOTest(unittest.TestCase):
diff --git a/django/contrib/gis/management/commands/inspectdb.py b/django/contrib/gis/management/commands/inspectdb.py
index 937bb8e..bbf40e1 100644
--- a/django/contrib/gis/management/commands/inspectdb.py
+++ b/django/contrib/gis/management/commands/inspectdb.py
@@ -1,6 +1,3 @@
-from optparse import make_option
-
-from django.core.management.base import CommandError
 from django.core.management.commands.inspectdb import Command as InspectDBCommand
 
 class Command(InspectDBCommand):
diff --git a/django/contrib/gis/management/commands/ogrinspect.py b/django/contrib/gis/management/commands/ogrinspect.py
index a495787..13f1c0a 100644
--- a/django/contrib/gis/management/commands/ogrinspect.py
+++ b/django/contrib/gis/management/commands/ogrinspect.py
@@ -1,4 +1,4 @@
-import os, sys
+import os
 from optparse import make_option
 from django.contrib.gis import gdal
 from django.contrib.gis.management.base import ArgsCommand, CommandError
diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py
index cca5dc9..0c0703d 100644
--- a/django/contrib/gis/maps/google/gmap.py
+++ b/django/contrib/gis/maps/google/gmap.py
@@ -1,10 +1,11 @@
 from django.conf import settings
-from django.contrib.gis import geos
 from django.template.loader import render_to_string
 from django.utils.safestring import mark_safe
 
-class GoogleMapException(Exception): pass
-from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker, GIcon
+class GoogleMapException(Exception):
+    pass
+
+from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker
 
 # The default Google Maps URL (for the API javascript)
 # TODO: Internationalize for Japan, UK, etc.
diff --git a/django/contrib/gis/maps/google/zoom.py b/django/contrib/gis/maps/google/zoom.py
index abc3fbf..7e7219f 100644
--- a/django/contrib/gis/maps/google/zoom.py
+++ b/django/contrib/gis/maps/google/zoom.py
@@ -1,6 +1,6 @@
 from django.contrib.gis.geos import GEOSGeometry, LinearRing, Polygon, Point
 from django.contrib.gis.maps.google.gmap import GoogleMapException
-from math import pi, sin, cos, log, exp, atan
+from math import pi, sin, log, exp, atan
 
 # Constants used for degree to radian conversion, and vice-versa.
 DTOR = pi / 180.
diff --git a/django/contrib/gis/shortcuts.py b/django/contrib/gis/shortcuts.py
index a6fb892..1fba780 100644
--- a/django/contrib/gis/shortcuts.py
+++ b/django/contrib/gis/shortcuts.py
@@ -1,11 +1,15 @@
-import cStringIO, zipfile
+try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
+import zipfile
 from django.conf import settings
 from django.http import HttpResponse
 from django.template import loader
 
 def compress_kml(kml):
     "Returns compressed KMZ from the given KML string."
-    kmz = cStringIO.StringIO()
+    kmz = StringIO()
     zf = zipfile.ZipFile(kmz, 'a', zipfile.ZIP_DEFLATED)
     zf.writestr('doc.kml', kml.encode(settings.DEFAULT_CHARSET))
     zf.close()
diff --git a/django/contrib/gis/tests/distapp/tests.py b/django/contrib/gis/tests/distapp/tests.py
index 4f81a91..4961a02 100644
--- a/django/contrib/gis/tests/distapp/tests.py
+++ b/django/contrib/gis/tests/distapp/tests.py
@@ -1,15 +1,12 @@
-import os
-from decimal import Decimal
-
 from django.db import connection
 from django.db.models import Q
-from django.contrib.gis.geos import GEOSGeometry, Point, LineString
+from django.contrib.gis.geos import GEOSGeometry, LineString
 from django.contrib.gis.measure import D # alias for Distance
 from django.contrib.gis.tests.utils import oracle, postgis, spatialite, no_oracle, no_spatialite
 from django.test import TestCase
 
-from models import AustraliaCity, Interstate, SouthTexasInterstate, \
-    SouthTexasCity, SouthTexasCityFt, CensusZipcode, SouthTexasZipcode
+from models import (AustraliaCity, Interstate, SouthTexasInterstate,
+    SouthTexasCity, SouthTexasCityFt, CensusZipcode, SouthTexasZipcode)
 
 class DistanceTest(TestCase):
 
diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py
index 324002e..be05964 100644
--- a/django/contrib/gis/tests/geo3d/tests.py
+++ b/django/contrib/gis/tests/geo3d/tests.py
@@ -5,9 +5,9 @@ from django.contrib.gis.db.models import Union, Extent3D
 from django.contrib.gis.geos import GEOSGeometry, Point, Polygon
 from django.contrib.gis.utils import LayerMapping, LayerMapError
 
-from models import City3D, Interstate2D, Interstate3D, \
-    InterstateProj2D, InterstateProj3D, \
-    Point2D, Point3D, MultiPoint3D, Polygon2D, Polygon3D
+from models import (City3D, Interstate2D, Interstate3D,
+    InterstateProj2D, InterstateProj3D,
+    Point2D, Point3D, MultiPoint3D, Polygon2D, Polygon3D)
 
 data_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
 city_file = os.path.join(data_path, 'cities', 'cities.shp')
diff --git a/django/contrib/gis/tests/geoapp/feeds.py b/django/contrib/gis/tests/geoapp/feeds.py
index 942b140..f2e8f73 100644
--- a/django/contrib/gis/tests/geoapp/feeds.py
+++ b/django/contrib/gis/tests/geoapp/feeds.py
@@ -1,6 +1,5 @@
 from django.contrib.gis import feeds
-from django.contrib.gis.tests.utils import mysql
-from models import City, Country
+from models import City
 
 class TestGeoRSS1(feeds.Feed):
     link = '/city/'
diff --git a/django/contrib/gis/tests/geoapp/test_regress.py b/django/contrib/gis/tests/geoapp/test_regress.py
index 0295526..d222194 100644
--- a/django/contrib/gis/tests/geoapp/test_regress.py
+++ b/django/contrib/gis/tests/geoapp/test_regress.py
@@ -1,5 +1,6 @@
-import os, unittest
-from django.contrib.gis.tests.utils import no_mysql, no_oracle, no_postgis, no_spatialite
+import os
+import unittest
+from django.contrib.gis.tests.utils import no_mysql, no_spatialite
 from django.contrib.gis.shortcuts import render_to_kmz
 from models import City
 
diff --git a/django/contrib/gis/tests/geoapp/test_sitemaps.py b/django/contrib/gis/tests/geoapp/test_sitemaps.py
index 16e0433..a6f0c9b 100644
--- a/django/contrib/gis/tests/geoapp/test_sitemaps.py
+++ b/django/contrib/gis/tests/geoapp/test_sitemaps.py
@@ -1,4 +1,7 @@
-import cStringIO
+try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
 from xml.dom import minidom
 import zipfile
 from django.conf import settings
@@ -60,7 +63,7 @@ class GeoSitemapTest(TestCase):
                     kml_doc = minidom.parseString(self.client.get(kml_url).content)
                 elif kml_type == 'kmz':
                     # Have to decompress KMZ before parsing.
-                    buf = cStringIO.StringIO(self.client.get(kml_url).content)
+                    buf = StringIO(self.client.get(kml_url).content)
                     zf = zipfile.ZipFile(buf)
                     self.assertEqual(1, len(zf.filelist))
                     self.assertEqual('doc.kml', zf.filelist[0].filename)
diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py
index 296f128..2960aee 100644
--- a/django/contrib/gis/tests/geoapp/tests.py
+++ b/django/contrib/gis/tests/geoapp/tests.py
@@ -1,12 +1,11 @@
 import re
 from django.db import connection
 from django.contrib.gis import gdal
-from django.contrib.gis.geos import fromstr, GEOSGeometry, \
-    Point, LineString, LinearRing, Polygon, GeometryCollection
-from django.contrib.gis.measure import Distance
-from django.contrib.gis.tests.utils import \
-    no_mysql, no_oracle, no_spatialite, \
-    mysql, oracle, postgis, spatialite
+from django.contrib.gis.geos import (fromstr, GEOSGeometry,
+    Point, LineString, LinearRing, Polygon, GeometryCollection)
+from django.contrib.gis.tests.utils import (
+    no_mysql, no_oracle, no_spatialite,
+    mysql, oracle, postgis, spatialite)
 from django.test import TestCase
 
 from models import Country, City, PennsylvaniaCity, State, Track
diff --git a/django/contrib/gis/tests/geogapp/tests.py b/django/contrib/gis/tests/geogapp/tests.py
index cb69ce9..b3a86cd 100644
--- a/django/contrib/gis/tests/geogapp/tests.py
+++ b/django/contrib/gis/tests/geogapp/tests.py
@@ -79,7 +79,6 @@ class GeographyTest(TestCase):
 
     def test06_geography_area(self):
         "Testing that Area calculations work on geography columns."
-        from django.contrib.gis.measure import A
         # SELECT ST_Area(poly) FROM geogapp_zipcode WHERE code='77002';
         ref_area = 5439084.70637573
         tol = 5
diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py
index 2214840..0480e43 100644
--- a/django/contrib/gis/tests/layermap/tests.py
+++ b/django/contrib/gis/tests/layermap/tests.py
@@ -4,13 +4,13 @@ from decimal import Decimal
 
 from django.utils.unittest import TestCase
 
-from django.contrib.gis.gdal import DataSource, OGRException
+from django.contrib.gis.gdal import DataSource
 from django.contrib.gis.tests.utils import mysql
 from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError, InvalidDecimal, MissingForeignKey
 
-from models import \
-    City, County, CountyFeat, Interstate, ICity1, ICity2, Invalid, State, \
-    city_mapping, co_mapping, cofeat_mapping, inter_mapping
+from models import (
+    City, County, CountyFeat, Interstate, ICity1, ICity2, Invalid, State,
+    city_mapping, co_mapping, cofeat_mapping, inter_mapping)
 
 shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir, 'data'))
 city_shp = os.path.join(shp_path, 'cities', 'cities.shp')
diff --git a/django/contrib/gis/tests/test_geoip.py b/django/contrib/gis/tests/test_geoip.py
index a9ab6a6..c092437 100644
--- a/django/contrib/gis/tests/test_geoip.py
+++ b/django/contrib/gis/tests/test_geoip.py
@@ -1,4 +1,5 @@
-import os, unittest
+import os
+import unittest
 from django.db import settings
 from django.contrib.gis.geos import GEOSGeometry
 from django.contrib.gis.utils import GeoIP, GeoIPException
diff --git a/django/contrib/gis/tests/test_spatialrefsys.py b/django/contrib/gis/tests/test_spatialrefsys.py
index d9c8c38..608f645 100644
--- a/django/contrib/gis/tests/test_spatialrefsys.py
+++ b/django/contrib/gis/tests/test_spatialrefsys.py
@@ -1,6 +1,6 @@
 from django.db import connection
 from django.contrib.gis.gdal import GDAL_VERSION
-from django.contrib.gis.tests.utils import mysql, no_mysql, oracle, postgis, spatialite
+from django.contrib.gis.tests.utils import no_mysql, oracle, postgis, spatialite
 from django.utils import unittest
 
 
diff --git a/django/contrib/gis/utils/geoip.py b/django/contrib/gis/utils/geoip.py
index eedaef9..29b949f 100644
--- a/django/contrib/gis/utils/geoip.py
+++ b/django/contrib/gis/utils/geoip.py
@@ -38,7 +38,8 @@
  >>> g.geos('24.124.1.80').wkt
  'POINT (-95.2087020874023438 39.0392990112304688)'
 """
-import os, re
+import os
+import re
 from ctypes import c_char_p, c_float, c_int, Structure, CDLL, POINTER
 from ctypes.util import find_library
 from django.conf import settings
diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py
index a970b07..d368112 100644
--- a/django/contrib/gis/utils/layermapping.py
+++ b/django/contrib/gis/utils/layermapping.py
@@ -7,15 +7,14 @@
    http://geodjango.org/docs/layermapping.html
 """
 import sys
-from datetime import date, datetime
 from decimal import Decimal
 from django.core.exceptions import ObjectDoesNotExist
 from django.db import connections, DEFAULT_DB_ALIAS
 from django.contrib.gis.db.models import GeometryField
-from django.contrib.gis.gdal import CoordTransform, DataSource, \
-    OGRException, OGRGeometry, OGRGeomType, SpatialReference
-from django.contrib.gis.gdal.field import \
-    OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime
+from django.contrib.gis.gdal import (CoordTransform, DataSource,
+    OGRException, OGRGeometry, OGRGeomType, SpatialReference)
+from django.contrib.gis.gdal.field import (
+    OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime)
 from django.db import models, transaction
 from django.contrib.localflavor.us.models import USStateField
 
diff --git a/django/contrib/gis/utils/ogrinspect.py b/django/contrib/gis/utils/ogrinspect.py
index 145bd22..fe4443c 100644
--- a/django/contrib/gis/utils/ogrinspect.py
+++ b/django/contrib/gis/utils/ogrinspect.py
@@ -8,7 +8,7 @@ Author: Travis Pinney, Dane Springmeyer, & Justin Bronn
 from itertools import izip
 # Requires GDAL to use.
 from django.contrib.gis.gdal import DataSource
-from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime
+from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString
 
 def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):
     """
diff --git a/django/contrib/localflavor/ar/forms.py b/django/contrib/localflavor/ar/forms.py
index 57b5f8b..36b7530 100644
--- a/django/contrib/localflavor/ar/forms.py
+++ b/django/contrib/localflavor/ar/forms.py
@@ -6,7 +6,6 @@ AR-specific Form helpers.
 from django.forms import ValidationError
 from django.core.validators import EMPTY_VALUES
 from django.forms.fields import RegexField, CharField, Select
-from django.utils.encoding import smart_unicode
 from django.utils.translation import ugettext_lazy as _
 
 class ARProvinceSelect(Select):
diff --git a/django/contrib/localflavor/au/models.py b/django/contrib/localflavor/au/models.py
index e2b897e..ce4f120 100644
--- a/django/contrib/localflavor/au/models.py
+++ b/django/contrib/localflavor/au/models.py
@@ -1,4 +1,3 @@
-from django.conf import settings
 from django.utils.translation import ugettext_lazy as _
 from django.db.models.fields import CharField
 
diff --git a/django/contrib/localflavor/be/forms.py b/django/contrib/localflavor/be/forms.py
index 6715e87..4e86d7e 100644
--- a/django/contrib/localflavor/be/forms.py
+++ b/django/contrib/localflavor/be/forms.py
@@ -1,10 +1,6 @@
 """
 Belgium-specific Form helpers
 """
-import re
-
-from django.core.validators import EMPTY_VALUES
-from django.forms import ValidationError
 from django.forms.fields import RegexField, Select
 from django.utils.translation import ugettext_lazy as _
 
diff --git a/django/contrib/localflavor/in_/forms.py b/django/contrib/localflavor/in_/forms.py
index c94c7e7..c09d257 100644
--- a/django/contrib/localflavor/in_/forms.py
+++ b/django/contrib/localflavor/in_/forms.py
@@ -7,7 +7,6 @@ from django.forms import ValidationError
 from django.forms.fields import Field, RegexField, Select
 from django.utils.encoding import smart_unicode
 from django.utils.translation import gettext
-import re
 
 
 class INZipCodeField(RegexField):
diff --git a/django/contrib/localflavor/jp/forms.py b/django/contrib/localflavor/jp/forms.py
index 248a938..11dc6e8 100644
--- a/django/contrib/localflavor/jp/forms.py
+++ b/django/contrib/localflavor/jp/forms.py
@@ -2,7 +2,6 @@
 JP-specific Form helpers
 """
 
-from django.forms import ValidationError
 from django.utils.translation import ugettext_lazy as _
 from django.forms.fields import RegexField, Select
 
diff --git a/django/contrib/localflavor/kw/forms.py b/django/contrib/localflavor/kw/forms.py
index 9429625..e671408 100644
--- a/django/contrib/localflavor/kw/forms.py
+++ b/django/contrib/localflavor/kw/forms.py
@@ -6,7 +6,7 @@ from datetime import date
 
 from django.core.validators import EMPTY_VALUES
 from django.forms import ValidationError
-from django.forms.fields import Field, RegexField
+from django.forms.fields import Field
 from django.utils.translation import gettext as _
 
 id_re = re.compile(r'^(?P<initial>\d{1})(?P<yy>\d\d)(?P<mm>\d\d)(?P<dd>\d\d)(?P<mid>\d{4})(?P<checksum>\d{1})')
diff --git a/django/contrib/localflavor/no/forms.py b/django/contrib/localflavor/no/forms.py
index abe3b80..930cc17 100644
--- a/django/contrib/localflavor/no/forms.py
+++ b/django/contrib/localflavor/no/forms.py
@@ -2,7 +2,8 @@
 Norwegian-specific Form helpers
 """
 
-import re, datetime
+import re
+import datetime
 from django.core.validators import EMPTY_VALUES
 from django.forms import ValidationError
 from django.forms.fields import Field, RegexField, Select
diff --git a/django/contrib/localflavor/pt/forms.py b/django/contrib/localflavor/pt/forms.py
index 2a563cf..3de7376 100644
--- a/django/contrib/localflavor/pt/forms.py
+++ b/django/contrib/localflavor/pt/forms.py
@@ -1,13 +1,13 @@
 """
 PT-specific Form helpers
 """
+import re
 
 from django.core.validators import EMPTY_VALUES
 from django.forms import ValidationError
-from django.forms.fields import Field, RegexField, Select
+from django.forms.fields import Field, RegexField
 from django.utils.encoding import smart_unicode
 from django.utils.translation import ugettext_lazy as _
-import re
 
 phone_digits_re = re.compile(r'^(\d{9}|(00|\+)\d*)$')
 
diff --git a/django/contrib/localflavor/ro/forms.py b/django/contrib/localflavor/ro/forms.py
index 3bfb0fa..1121f8e 100644
--- a/django/contrib/localflavor/ro/forms.py
+++ b/django/contrib/localflavor/ro/forms.py
@@ -2,9 +2,6 @@
 """
 Romanian specific form helpers.
 """
-
-import re
-
 from django.core.validators import EMPTY_VALUES
 from django.forms import ValidationError, Field, RegexField, Select
 from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/localflavor/ru/forms.py b/django/contrib/localflavor/ru/forms.py
index d091eab..a8662b5 100644
--- a/django/contrib/localflavor/ru/forms.py
+++ b/django/contrib/localflavor/ru/forms.py
@@ -3,9 +3,7 @@ Russian-specific forms helpers
 """
 import re
 
-from django.core.validators import EMPTY_VALUES
-from django.forms import ValidationError
-from django.forms.fields import CharField, Select, RegexField
+from django.forms.fields import RegexField, Select
 from django.utils.translation import ugettext_lazy as _
 
 phone_digits_re = re.compile(r'^(?:[78]-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')
diff --git a/django/contrib/localflavor/se/utils.py b/django/contrib/localflavor/se/utils.py
index 50d8ac1..5f65d8f 100644
--- a/django/contrib/localflavor/se/utils.py
+++ b/django/contrib/localflavor/se/utils.py
@@ -1,4 +1,3 @@
-import re
 import datetime
 
 def id_number_checksum(gd):
diff --git a/django/contrib/localflavor/us/models.py b/django/contrib/localflavor/us/models.py
index d5f7976..7cec205 100644
--- a/django/contrib/localflavor/us/models.py
+++ b/django/contrib/localflavor/us/models.py
@@ -1,4 +1,3 @@
-from django.conf import settings
 from django.utils.translation import ugettext_lazy as _
 from django.db.models.fields import CharField
 from django.contrib.localflavor.us.us_states import STATE_CHOICES
diff --git a/django/contrib/localflavor/uy/forms.py b/django/contrib/localflavor/uy/forms.py
index 3f70cf3..2d90e52 100644
--- a/django/contrib/localflavor/uy/forms.py
+++ b/django/contrib/localflavor/uy/forms.py
@@ -2,8 +2,6 @@
 """
 UY-specific form helpers.
 """
-import re
-
 from django.core.validators import EMPTY_VALUES
 from django.forms.fields import Select, RegexField
 from django.forms import ValidationError
diff --git a/django/contrib/messages/api.py b/django/contrib/messages/api.py
index 9880d7f..8e08655 100644
--- a/django/contrib/messages/api.py
+++ b/django/contrib/messages/api.py
@@ -1,6 +1,5 @@
 from django.contrib.messages import constants
 from django.contrib.messages.storage import default_storage
-from django.utils.functional import lazy, memoize
 
 __all__ = (
     'add_message', 'get_messages',
diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py
index 45a20d0..c45dff4 100644
--- a/django/contrib/messages/storage/cookie.py
+++ b/django/contrib/messages/storage/cookie.py
@@ -1,5 +1,4 @@
 from django.conf import settings
-from django.contrib.messages import constants
 from django.contrib.messages.storage.base import BaseStorage, Message
 from django.http import SimpleCookie
 from django.utils import simplejson as json
diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py
index c6886a8..416d16c 100644
--- a/django/contrib/messages/tests/base.py
+++ b/django/contrib/messages/tests/base.py
@@ -1,5 +1,3 @@
-import warnings
-
 from django import http
 from django.test import TestCase
 from django.conf import settings
diff --git a/django/contrib/messages/tests/cookie.py b/django/contrib/messages/tests/cookie.py
index 95e1f99..f22ed39 100644
--- a/django/contrib/messages/tests/cookie.py
+++ b/django/contrib/messages/tests/cookie.py
@@ -1,7 +1,7 @@
 from django.contrib.messages import constants
 from django.contrib.messages.tests.base import BaseTest
-from django.contrib.messages.storage.cookie import CookieStorage, \
-                                            MessageEncoder, MessageDecoder
+from django.contrib.messages.storage.cookie import (CookieStorage,
+    MessageEncoder, MessageDecoder)
 from django.contrib.messages.storage.base import Message
 from django.utils import simplejson as json
 from django.conf import settings
diff --git a/django/contrib/messages/tests/fallback.py b/django/contrib/messages/tests/fallback.py
index 9e4f657..0aa6500 100644
--- a/django/contrib/messages/tests/fallback.py
+++ b/django/contrib/messages/tests/fallback.py
@@ -1,11 +1,11 @@
 from django.contrib.messages import constants
-from django.contrib.messages.storage.fallback import FallbackStorage, \
-    CookieStorage
+from django.contrib.messages.storage.fallback import (FallbackStorage,
+    CookieStorage)
 from django.contrib.messages.tests.base import BaseTest
-from django.contrib.messages.tests.cookie import set_cookie_data, \
-    stored_cookie_messages_count
-from django.contrib.messages.tests.session import set_session_data, \
-    stored_session_messages_count
+from django.contrib.messages.tests.cookie import (set_cookie_data,
+    stored_cookie_messages_count)
+from django.contrib.messages.tests.session import (set_session_data,
+    stored_session_messages_count)
 
 
 class FallbackTest(BaseTest):
diff --git a/django/contrib/messages/tests/urls.py b/django/contrib/messages/tests/urls.py
index 5191f34..263b0a8 100644
--- a/django/contrib/messages/tests/urls.py
+++ b/django/contrib/messages/tests/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls.defaults import *
 from django.contrib import messages
 from django.core.urlresolvers import reverse
 from django.http import HttpResponseRedirect, HttpResponse
-from django.shortcuts import render_to_response, redirect
 from django.template import RequestContext, Template
 from django.template.response import TemplateResponse
 from django.views.decorators.cache import never_cache
diff --git a/django/contrib/sessions/backends/base.py b/django/contrib/sessions/backends/base.py
index 1c7c188..050ed7b 100644
--- a/django/contrib/sessions/backends/base.py
+++ b/django/contrib/sessions/backends/base.py
@@ -2,7 +2,6 @@ import base64
 import hashlib
 import os
 import random
-import sys
 import time
 from datetime import datetime, timedelta
 try:
diff --git a/django/contrib/sessions/backends/db.py b/django/contrib/sessions/backends/db.py
index 9a53790..220046f 100644
--- a/django/contrib/sessions/backends/db.py
+++ b/django/contrib/sessions/backends/db.py
@@ -1,5 +1,4 @@
 import datetime
-from django.conf import settings
 from django.contrib.sessions.backends.base import SessionBase, CreateError
 from django.core.exceptions import SuspiciousOperation
 from django.db import IntegrityError, transaction, router
diff --git a/django/contrib/sessions/models.py b/django/contrib/sessions/models.py
index 1d82a99..0179c35 100644
--- a/django/contrib/sessions/models.py
+++ b/django/contrib/sessions/models.py
@@ -1,6 +1,3 @@
-import base64
-import cPickle as pickle
-
 from django.db import models
 from django.utils.translation import ugettext_lazy as _
 
diff --git a/django/contrib/sitemaps/__init__.py b/django/contrib/sitemaps/__init__.py
index 6b8d5a0..a225b77 100644
--- a/django/contrib/sitemaps/__init__.py
+++ b/django/contrib/sitemaps/__init__.py
@@ -1,4 +1,4 @@
-from django.contrib.sites.models import Site, get_current_site
+from django.contrib.sites.models import Site
 from django.core import urlresolvers, paginator
 from django.core.exceptions import ImproperlyConfigured
 import urllib
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py
index 513adb4..f7573b2 100644
--- a/django/core/cache/backends/base.py
+++ b/django/core/cache/backends/base.py
@@ -2,7 +2,6 @@
 
 import warnings
 
-from django.conf import settings
 from django.core.exceptions import ImproperlyConfigured, DjangoRuntimeWarning
 from django.utils.encoding import smart_str
 from django.utils.importlib import import_module
diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py
index 495812a..b4743af 100644
--- a/django/core/cache/backends/db.py
+++ b/django/core/cache/backends/db.py
@@ -2,12 +2,13 @@
 
 from django.core.cache.backends.base import BaseCache
 from django.db import connections, router, transaction, DatabaseError
-import base64, time
+import base64
 from datetime import datetime
 try:
     import cPickle as pickle
 except ImportError:
     import pickle
+import time
 
 class Options(object):
     """A class that will quack like a Django model _meta class.
diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py
index e452498..1e1d97e 100644
--- a/django/core/cache/backends/memcached.py
+++ b/django/core/cache/backends/memcached.py
@@ -4,7 +4,6 @@ import time
 from threading import local
 
 from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError
-from django.utils import importlib
 
 class BaseMemcachedCache(BaseCache):
     def __init__(self, server, params, library, value_not_found_exception):
diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py
index 5affea4..eba9dd3 100644
--- a/django/core/handlers/modpython.py
+++ b/django/core/handlers/modpython.py
@@ -1,5 +1,4 @@
 import os
-from pprint import pformat
 import sys
 from warnings import warn
 
@@ -8,7 +7,7 @@ from django.core import signals
 from django.core.handlers.base import BaseHandler
 from django.core.urlresolvers import set_script_prefix
 from django.utils import datastructures
-from django.utils.encoding import force_unicode, smart_str, iri_to_uri
+from django.utils.encoding import force_unicode, iri_to_uri
 from django.utils.log import getLogger
 
 logger = getLogger('django.request')
diff --git a/django/core/handlers/profiler-hotshot.py b/django/core/handlers/profiler-hotshot.py
index 6cf94b0..0522de6 100644
--- a/django/core/handlers/profiler-hotshot.py
+++ b/django/core/handlers/profiler-hotshot.py
@@ -1,4 +1,7 @@
-import hotshot, time, os
+import hotshot
+import os
+import time
+
 from django.core.handlers.modpython import ModPythonHandler
 
 PROFILE_DATA_DIR = "/var/log/cmsprofile"
diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
index 2acb3b1..d288581 100644
--- a/django/core/handlers/wsgi.py
+++ b/django/core/handlers/wsgi.py
@@ -1,4 +1,3 @@
-from pprint import pformat
 import sys
 from threading import Lock
 try:
diff --git a/django/core/mail/__init__.py b/django/core/mail/__init__.py
index 2c71b11..f363fc5 100644
--- a/django/core/mail/__init__.py
+++ b/django/core/mail/__init__.py
@@ -11,11 +11,11 @@ from django.utils.importlib import import_module
 # django/core/mail.py before the introduction of email
 # backends and the subsequent reorganization (See #10355)
 from django.core.mail.utils import CachedDnsName, DNS_NAME
-from django.core.mail.message import \
-    EmailMessage, EmailMultiAlternatives, \
-    SafeMIMEText, SafeMIMEMultipart, \
-    DEFAULT_ATTACHMENT_MIME_TYPE, make_msgid, \
-    BadHeaderError, forbid_multi_line_headers
+from django.core.mail.message import (
+    EmailMessage, EmailMultiAlternatives,
+    SafeMIMEText, SafeMIMEMultipart,
+    DEFAULT_ATTACHMENT_MIME_TYPE, make_msgid,
+    BadHeaderError, forbid_multi_line_headers)
 from django.core.mail.backends.smtp import EmailBackend as _SMTPConnection
 
 def get_connection(backend=None, fail_silently=False, **kwds):
diff --git a/django/core/management/commands/reset.py b/django/core/management/commands/reset.py
index 8aa7e88..9539212 100644
--- a/django/core/management/commands/reset.py
+++ b/django/core/management/commands/reset.py
@@ -1,6 +1,5 @@
 from optparse import make_option
 
-from django.conf import settings
 from django.core.management.base import AppCommand, CommandError
 from django.core.management.color import no_style
 from django.core.management.sql import sql_reset
diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py
index 6afaf21..ffc869c 100644
--- a/django/core/serializers/base.py
+++ b/django/core/serializers/base.py
@@ -5,8 +5,7 @@ Module for abstract serializer/unserializer base classes.
 from StringIO import StringIO
 
 from django.db import models
-from django.utils.encoding import smart_str, smart_unicode
-from django.utils import datetime_safe
+from django.utils.encoding import smart_unicode
 
 class SerializerDoesNotExist(KeyError):
     """The requested serializer was not found."""
diff --git a/django/core/servers/fastcgi.py b/django/core/servers/fastcgi.py
index 7e724c2..9f80d2b 100644
--- a/django/core/servers/fastcgi.py
+++ b/django/core/servers/fastcgi.py
@@ -12,8 +12,9 @@ Run with the extra option "help" for a list of additional options you can
 pass to this server.
 """
 
+import os
+import sys
 from django.utils import importlib
-import sys, os
 
 __version__ = "0.1"
 __all__ = ["runfastcgi"]
diff --git a/django/db/__init__.py b/django/db/__init__.py
index 2148cf0..8395468 100644
--- a/django/db/__init__.py
+++ b/django/db/__init__.py
@@ -1,8 +1,8 @@
 from django.conf import settings
 from django.core import signals
 from django.core.exceptions import ImproperlyConfigured
-from django.db.utils import ConnectionHandler, ConnectionRouter, load_backend, DEFAULT_DB_ALIAS, \
-                            DatabaseError, IntegrityError
+from django.db.utils import (ConnectionHandler, ConnectionRouter,
+    load_backend, DEFAULT_DB_ALIAS, DatabaseError, IntegrityError)
 
 __all__ = ('backend', 'connection', 'connections', 'router', 'DatabaseError',
     'IntegrityError', 'DEFAULT_DB_ALIAS')
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index b64fb01..1c3bc7e 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -1,4 +1,3 @@
-import decimal
 try:
     import thread
 except ImportError:
diff --git a/django/db/backends/dummy/base.py b/django/db/backends/dummy/base.py
index 7de48c8..a2aef52 100644
--- a/django/db/backends/dummy/base.py
+++ b/django/db/backends/dummy/base.py
@@ -7,6 +7,8 @@ Each of these API functions, except connection.close(), raises
 ImproperlyConfigured.
 """
 
+import decimal
+
 from django.core.exceptions import ImproperlyConfigured
 from django.db.backends import *
 from django.db.backends.creation import BaseDatabaseCreation
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index 6d02aa7..3338690 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -4,6 +4,7 @@ MySQL database backend for Django.
 Requires MySQLdb: http://sourceforge.net/projects/mysql-python
 """
 
+import decimal
 import re
 import sys
 
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 42de0dd..930b1bb 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -6,7 +6,7 @@ Requires cx_Oracle: http://cx-oracle.sourceforge.net/
 
 
 import datetime
-from decimal import Decimal
+import decimal
 import sys
 
 
@@ -730,7 +730,7 @@ def _rowfactory(row, cursor):
                     # This will normally be an integer from a sequence,
                     # but it could be a decimal value.
                     if '.' in value:
-                        value = Decimal(value)
+                        value = decimal.Decimal(value)
                     else:
                         value = int(value)
                 else:
@@ -743,12 +743,12 @@ def _rowfactory(row, cursor):
                 if scale == 0:
                     value = int(value)
                 else:
-                    value = Decimal(value)
+                    value = decimal.Decimal(value)
             elif '.' in value:
                 # No type information. This normally comes from a
                 # mathematical expression in the SELECT list. Guess int
                 # or Decimal based on whether it has a decimal point.
-                value = Decimal(value)
+                value = decimal.Decimal(value)
             else:
                 value = int(value)
         elif desc[1] in (Database.STRING, Database.FIXED_CHAR,
diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py
index 0403e0a..893b5dd 100644
--- a/django/db/backends/oracle/creation.py
+++ b/django/db/backends/oracle/creation.py
@@ -1,4 +1,5 @@
-import sys, time
+import sys
+import time
 from django.db.backends.creation import BaseDatabaseCreation
 
 TEST_DATABASE_PREFIX = 'test_'
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index 67e2877..122ec78 100644
--- a/django/db/backends/postgresql_psycopg2/base.py
+++ b/django/db/backends/postgresql_psycopg2/base.py
@@ -3,7 +3,6 @@ PostgreSQL database backend for Django.
 
 Requires psycopg 2: http://initd.org/projects/psycopg2
 """
-
 import sys
 
 from django.db import utils
diff --git a/django/db/backends/postgresql_psycopg2/operations.py b/django/db/backends/postgresql_psycopg2/operations.py
index 3315913..3376ca8 100644
--- a/django/db/backends/postgresql_psycopg2/operations.py
+++ b/django/db/backends/postgresql_psycopg2/operations.py
@@ -1,5 +1,3 @@
-import re
-
 from django.db.backends import BaseDatabaseOperations
 
 
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index 5b4a1c2..79c5ede 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -5,9 +5,10 @@ Works with either the pysqlite2 module or the sqlite3 module in the
 standard library.
 """
 
+import datetime
+import decimal
 import re
 import sys
-import datetime
 
 from django.db import utils
 from django.db.backends import *
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 31310ea..14f6ee7 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1,6 +1,5 @@
 import copy
 import sys
-import types
 from functools import update_wrapper
 from itertools import izip
 
@@ -8,8 +7,7 @@ import django.db.models.manager     # Imported to register signal handler.
 from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError, ValidationError, NON_FIELD_ERRORS
 from django.core import validators
 from django.db.models.fields import AutoField, FieldDoesNotExist
-from django.db.models.fields.related import (OneToOneRel, ManyToOneRel,
-    OneToOneField, add_lazy_relation)
+from django.db.models.fields.related import ManyToOneRel, OneToOneField, add_lazy_relation
 from django.db.models.query import Q
 from django.db.models.query_utils import DeferredAttribute
 from django.db.models.deletion import Collector
diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
index 310e3af..e165346 100644
--- a/django/db/models/deletion.py
+++ b/django/db/models/deletion.py
@@ -3,7 +3,6 @@ from operator import attrgetter
 
 from django.db import connections, transaction, IntegrityError
 from django.db.models import signals, sql
-from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE
 from django.utils.datastructures import SortedDict
 
 
diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
index 50dc236..d0dbf23 100644
--- a/django/db/models/fields/files.py
+++ b/django/db/models/fields/files.py
@@ -1,18 +1,14 @@
 import datetime
 import os
 
-from django.conf import settings
+from django import forms
 from django.db.models.fields import Field
-from django.core.files.base import File, ContentFile
+from django.core.files.base import File
 from django.core.files.storage import default_storage
-from django.core.files.images import ImageFile, get_image_dimensions
-from django.core.files.uploadedfile import UploadedFile
-from django.utils.functional import curry
+from django.core.files.images import ImageFile
 from django.db.models import signals
 from django.utils.encoding import force_unicode, smart_str
-from django.utils.translation import ugettext_lazy, ugettext as _
-from django import forms
-from django.db.models.loading import cache
+from django.utils.translation import ugettext_lazy as _
 
 class FieldFile(File):
     def __init__(self, instance, field, name):
@@ -215,7 +211,7 @@ class FileField(Field):
     # The descriptor to use for accessing the attribute off of the class.
     descriptor_class = FileDescriptor
 
-    description = ugettext_lazy("File path")
+    description = _("File path")
 
     def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs):
         for arg in ('primary_key', 'unique'):
@@ -321,7 +317,7 @@ class ImageFieldFile(ImageFile, FieldFile):
 class ImageField(FileField):
     attr_class = ImageFieldFile
     descriptor_class = ImageFileDescriptor
-    description = ugettext_lazy("File path")
+    description = _("File path")
 
     def __init__(self, verbose_name=None, name=None, width_field=None, height_field=None, **kwargs):
         self.width_field, self.height_field = width_field, height_field
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index cedf308..e7f4b9b 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -1,5 +1,4 @@
-from django.conf import settings
-from django.db import connection, router, transaction
+from django.db import connection, router
 from django.db.backends import util
 from django.db.models import signals, get_model
 from django.db.models.fields import (AutoField, Field, IntegerField,
@@ -9,8 +8,7 @@ from django.db.models.query import QuerySet
 from django.db.models.query_utils import QueryWrapper
 from django.db.models.deletion import CASCADE
 from django.utils.encoding import smart_unicode
-from django.utils.translation import (ugettext_lazy as _, string_concat,
-    ungettext, ugettext)
+from django.utils.translation import ugettext_lazy as _, string_concat
 from django.utils.functional import curry
 from django.core import exceptions
 from django import forms
diff --git a/django/db/models/loading.py b/django/db/models/loading.py
index 2c35fdb..03cdcc2 100644
--- a/django/db/models/loading.py
+++ b/django/db/models/loading.py
@@ -6,7 +6,6 @@ from django.utils.datastructures import SortedDict
 from django.utils.importlib import import_module
 from django.utils.module_loading import module_has_submodule
 
-import imp
 import sys
 import os
 import threading
diff --git a/django/db/models/manager.py b/django/db/models/manager.py
index 4fa4c4a..bdd86bb 100644
--- a/django/db/models/manager.py
+++ b/django/db/models/manager.py
@@ -1,5 +1,4 @@
 import copy
-from django.conf import settings
 from django.db import router
 from django.db.models.query import QuerySet, EmptyQuerySet, insert_query, RawQuerySet
 from django.db.models import signals
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 6a6a829..c719d13 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -3,15 +3,12 @@ The main QuerySet implementation. This provides the public API for the ORM.
 """
 
 import copy
-from itertools import izip
 
 from django.db import connections, router, transaction, IntegrityError
-from django.db.models.aggregates import Aggregate
-from django.db.models.fields import DateField
 from django.db.models.query_utils import (Q, select_related_descend,
     deferred_class_factory, InvalidQuery)
 from django.db.models.deletion import Collector
-from django.db.models import signals, sql
+from django.db.models import sql
 
 # Used to control how many objects are worked with at once in some cases (e.g.
 # when deleting objects).
diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
index 69b19f1..a56ab5c 100644
--- a/django/db/models/query_utils.py
+++ b/django/db/models/query_utils.py
@@ -10,7 +10,6 @@ import weakref
 
 from django.db.backends import util
 from django.utils import tree
-from django.utils.datastructures import SortedDict
 
 
 class InvalidQuery(Exception):
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 841ec12..b4502d8 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -5,8 +5,8 @@ from django.db.backends.util import truncate_name
 from django.db.models.sql.constants import *
 from django.db.models.sql.datastructures import EmptyResultSet
 from django.db.models.sql.expressions import SQLEvaluator
-from django.db.models.sql.query import get_proxied_model, get_order_dir, \
-     select_related_descend, Query
+from django.db.models.sql.query import (get_proxied_model, get_order_dir,
+     select_related_descend, Query)
 from django.db.utils import DatabaseError
 
 class SQLCompiler(object):
diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py
index 003bf43..ecde857 100644
--- a/django/db/models/sql/subqueries.py
+++ b/django/db/models/sql/subqueries.py
@@ -3,11 +3,9 @@ Query subclasses which provide extra functionality beyond simple data retrieval.
 """
 
 from django.core.exceptions import FieldError
-from django.db import connections
 from django.db.models.fields import DateField, FieldDoesNotExist
 from django.db.models.sql.constants import *
 from django.db.models.sql.datastructures import Date
-from django.db.models.sql.expressions import SQLEvaluator
 from django.db.models.sql.query import Query
 from django.db.models.sql.where import AND, Constraint
 
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 2427a52..3e9dbf0 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -6,7 +6,6 @@ from itertools import repeat
 
 from django.utils import tree
 from django.db.models.fields import Field
-from django.db.models.query_utils import QueryWrapper
 from datastructures import EmptyResultSet, FullResultSet
 
 # Connection types
diff --git a/django/db/transaction.py b/django/db/transaction.py
index 104243a..4ecd2d1 100644
--- a/django/db/transaction.py
+++ b/django/db/transaction.py
@@ -13,10 +13,8 @@ or implicit commits or rollbacks.
 """
 from __future__ import with_statement
 
-import sys
 from functools import wraps
 
-from django.conf import settings
 from django.db import connections, DEFAULT_DB_ALIAS
 
 
diff --git a/django/dispatch/saferef.py b/django/dispatch/saferef.py
index f446447..1c7d164 100644
--- a/django/dispatch/saferef.py
+++ b/django/dispatch/saferef.py
@@ -5,7 +5,8 @@ Provides a way to safely weakref any function, including bound methods (which
 aren't handled by the core weakref module).
 """
 
-import weakref, traceback
+import traceback
+import weakref
 
 def safeRef(target, onDelete = None):
     """Return a *safe* weak reference to a callable target
diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py
index d75e903..5145578 100644
--- a/django/forms/extras/widgets.py
+++ b/django/forms/extras/widgets.py
@@ -2,7 +2,6 @@
 Extra HTML Widget classes
 """
 
-import time
 import datetime
 import re
 
diff --git a/django/forms/models.py b/django/forms/models.py
index b34f4d0..45e8d69 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -8,8 +8,7 @@ from django.utils.datastructures import SortedDict
 from django.utils.text import get_text_list, capfirst
 from django.utils.translation import ugettext_lazy as _, ugettext
 
-from django.core.exceptions import ValidationError, NON_FIELD_ERRORS, \
-                                   FieldError
+from django.core.exceptions import ValidationError, NON_FIELD_ERRORS, FieldError
 from django.core.validators import EMPTY_VALUES
 from util import ErrorList
 from forms import BaseForm, get_declared_fields
diff --git a/django/middleware/http.py b/django/middleware/http.py
index e98858f..86e46ce 100644
--- a/django/middleware/http.py
+++ b/django/middleware/http.py
@@ -1,4 +1,3 @@
-from django.core.exceptions import MiddlewareNotUsed
 from django.utils.http import http_date, parse_http_date_safe
 
 class ConditionalGetMiddleware(object):
diff --git a/django/template/base.py b/django/template/base.py
index b96e446..9a7f55f 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -1,4 +1,3 @@
-import imp
 import re
 from functools import partial
 from inspect import getargspec
@@ -7,7 +6,6 @@ from django.conf import settings
 from django.template.context import Context, RequestContext, ContextPopException
 from django.utils.importlib import import_module
 from django.utils.itercompat import is_iterable
-from django.utils.functional import Promise
 from django.utils.text import smart_split, unescape_string_literal, get_text_list
 from django.utils.encoding import smart_unicode, force_unicode, smart_str
 from django.utils.translation import ugettext_lazy
diff --git a/django/template/context.py b/django/template/context.py
index cb1c708..8f70d70 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -1,7 +1,6 @@
 from copy import copy
 from django.core.exceptions import ImproperlyConfigured
 from django.utils.importlib import import_module
-from django.http import HttpRequest
 
 # Cache of actual callables.
 _standard_context_processors = None
diff --git a/django/template/debug.py b/django/template/debug.py
index a9e3c4f..bf2a53b 100644
--- a/django/template/debug.py
+++ b/django/template/debug.py
@@ -1,4 +1,3 @@
-from django.conf import settings
 from django.template.base import Lexer, Parser, tag_re, NodeList, VariableNode, TemplateSyntaxError
 from django.utils.encoding import force_unicode
 from django.utils.html import escape
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index 1eceaf4..df74b61 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -5,8 +5,12 @@ import re
 from datetime import datetime
 from itertools import groupby, cycle as itertools_cycle
 
-from django.template.base import Node, NodeList, Template, Context, Variable
-from django.template.base import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END
+from django.template.base import Node, NodeList, Template
+from django.template.base import (TemplateSyntaxError, VariableDoesNotExist,
+        BLOCK_TAG_START, BLOCK_TAG_END,
+        VARIABLE_TAG_START, VARIABLE_TAG_END,
+        SINGLE_BRACE_START, SINGLE_BRACE_END,
+        COMMENT_TAG_START, COMMENT_TAG_END)
 from django.template.base import get_library, Library, InvalidTemplateLibrary
 from django.template.smartif import IfParser, Literal
 from django.template.defaultfilters import date
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index f5cac33..3e2fb1b 100644
--- a/django/template/loader_tags.py
+++ b/django/template/loader_tags.py
@@ -1,6 +1,4 @@
-from django.template.base import TemplateSyntaxError, TemplateDoesNotExist, Variable
-from django.template.base import Library, Node, TextNode
-from django.template.context import Context
+from django.template.base import TemplateSyntaxError, Library, Node, TextNode
 from django.template.defaulttags import token_kwargs
 from django.template.loader import get_template
 from django.conf import settings
diff --git a/django/template/loaders/cached.py b/django/template/loaders/cached.py
index 5b351ad..3ed9cf3 100644
--- a/django/template/loaders/cached.py
+++ b/django/template/loaders/cached.py
@@ -4,10 +4,8 @@ to load templates from them in order, caching the result.
 """
 
 import hashlib
-from django.core.exceptions import ImproperlyConfigured
 from django.template.base import TemplateDoesNotExist
 from django.template.loader import BaseLoader, get_template_from_string, find_template_loader, make_origin
-from django.utils.importlib import import_module
 
 class Loader(BaseLoader):
     is_usable = True
diff --git a/django/template/smartif.py b/django/template/smartif.py
index e835e0f..54d74b4 100644
--- a/django/template/smartif.py
+++ b/django/template/smartif.py
@@ -1,7 +1,6 @@
 """
 Parser and utilities for the smart 'if' tag
 """
-import operator
 
 # Using a simple top down parser, as described here:
 #    http://effbot.org/zone/simple-top-down-parsing.htm.
diff --git a/django/templatetags/cache.py b/django/templatetags/cache.py
index 495623d..8183452 100644
--- a/django/templatetags/cache.py
+++ b/django/templatetags/cache.py
@@ -2,7 +2,6 @@ import hashlib
 from django.template import Library, Node, TemplateSyntaxError, Variable, VariableDoesNotExist
 from django.template import resolve_variable
 from django.core.cache import cache
-from django.utils.encoding import force_unicode
 from django.utils.http import urlquote
 
 register = Library()
diff --git a/django/templatetags/future.py b/django/templatetags/future.py
index 3d98879..248c865 100644
--- a/django/templatetags/future.py
+++ b/django/templatetags/future.py
@@ -1,7 +1,5 @@
-from django.conf import settings
-from django.template import Library, Node, Template, TemplateSyntaxError
-from django.template.defaulttags import kwarg_re, include_is_allowed, SsiNode, URLNode
-from django.utils.encoding import smart_str
+from django.template import Library, TemplateSyntaxError
+from django.template.defaulttags import kwarg_re, SsiNode, URLNode
 
 
 register = Library()
diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py
index 1782136..492e763 100644
--- a/django/templatetags/i18n.py
+++ b/django/templatetags/i18n.py
@@ -1,11 +1,10 @@
 import re
 
-from django.template import Node, Variable, VariableNode
+from django.template import Node, Variable
 from django.template import TemplateSyntaxError, TokenParser, Library
 from django.template import TOKEN_TEXT, TOKEN_VAR
 from django.template.base import _render_value_in_context
 from django.utils import translation
-from django.utils.encoding import force_unicode
 from django.template.defaulttags import token_kwargs
 
 register = Library()
diff --git a/django/templatetags/l10n.py b/django/templatetags/l10n.py
index 5191e69..12cf136 100644
--- a/django/templatetags/l10n.py
+++ b/django/templatetags/l10n.py
@@ -1,4 +1,3 @@
-from django.conf import settings
 from django.template import Node
 from django.template import TemplateSyntaxError, Library
 from django.utils import formats
diff --git a/django/test/client.py b/django/test/client.py
index 4335f21..10d8727 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -5,7 +5,7 @@ import re
 import mimetypes
 import warnings
 from copy import copy
-from urlparse import urlparse, urlunparse, urlsplit
+from urlparse import urlparse, urlsplit
 try:
     from cStringIO import StringIO
 except ImportError:
@@ -24,7 +24,7 @@ from django.utils.encoding import smart_str
 from django.utils.http import urlencode
 from django.utils.importlib import import_module
 from django.utils.itercompat import is_iterable
-from django.db import transaction, close_connection
+from django.db import close_connection
 from django.test.utils import ContextList
 
 __all__ = ('Client', 'RequestFactory', 'encode_file', 'encode_multipart')
diff --git a/django/test/testcases.py b/django/test/testcases.py
index 02717ff..e767712 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -6,7 +6,7 @@ from functools import wraps
 from urlparse import urlsplit, urlunsplit
 from xml.dom.minidom import parseString, Node
 
-from django.conf import settings, UserSettingsHolder
+from django.conf import settings
 from django.core import mail
 from django.core.management import call_command
 from django.core.signals import request_started
diff --git a/django/test/utils.py b/django/test/utils.py
index 19a3190..180028a 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -1,12 +1,8 @@
 from __future__ import with_statement
 
-import sys
-import time
-import os
 import warnings
 from django.conf import settings, UserSettingsHolder
 from django.core import mail
-from django.core.mail.backends import locmem
 from django.test.signals import template_rendered, setting_changed
 from django.template import Template, loader, TemplateDoesNotExist
 from django.template.loaders import cached
diff --git a/django/utils/cache.py b/django/utils/cache.py
index bd23940..81a8279 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -26,7 +26,6 @@ from django.core.cache import get_cache
 from django.utils.encoding import smart_str, iri_to_uri
 from django.utils.http import http_date
 from django.utils.translation import get_language
-from django.http import HttpRequest
 
 cc_delim_re = re.compile(r'\s*,\s*')
 
diff --git a/django/utils/log.py b/django/utils/log.py
index 969a9d9..d25db69 100644
--- a/django/utils/log.py
+++ b/django/utils/log.py
@@ -1,5 +1,4 @@
 import logging
-import sys
 import traceback
 
 from django.conf import settings
diff --git a/django/utils/text.py b/django/utils/text.py
index 00c999c..6c574b4 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -1,8 +1,16 @@
 import re
+from gzip import GzipFile
+from htmlentitydefs import name2codepoint
+
+try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
+
 from django.utils.encoding import force_unicode
 from django.utils.functional import allow_lazy
 from django.utils.translation import ugettext_lazy, ugettext as _
-from htmlentitydefs import name2codepoint
+
 
 # Capitalizes the first letter of a string.
 capfirst = lambda x: x and force_unicode(x)[0].upper() + force_unicode(x)[1:]
@@ -180,9 +188,8 @@ phone2numeric = allow_lazy(phone2numeric)
 # From http://www.xhaus.com/alan/python/httpcomp.html#gzip
 # Used with permission.
 def compress_string(s):
-    import cStringIO, gzip
-    zbuf = cStringIO.StringIO()
-    zfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
+    zbuf = StringIO()
+    zfile = GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
     zfile.write(s)
     zfile.close()
     return zbuf.getvalue()
diff --git a/django/utils/timesince.py b/django/utils/timesince.py
index c584ce6..369a3e2 100644
--- a/django/utils/timesince.py
+++ b/django/utils/timesince.py
@@ -1,5 +1,4 @@
 import datetime
-import time
 
 from django.utils.tzinfo import LocalTimezone
 from django.utils.translation import ungettext, ugettext
diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py
index 5622c03..170cd5d 100644
--- a/django/utils/translation/trans_null.py
+++ b/django/utils/translation/trans_null.py
@@ -2,7 +2,6 @@
 # that don't actually do anything. This is purely for performance, so that
 # settings.USE_I18N = False can use this module rather than trans_real.py.
 
-import warnings
 from django.conf import settings
 from django.utils.encoding import force_unicode
 from django.utils.safestring import mark_safe, SafeData
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 9e8285b..345e46d 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -4,11 +4,14 @@ import locale
 import os
 import re
 import sys
-import warnings
 import gettext as gettext_module
-from cStringIO import StringIO
 from threading import local
 
+try:
+    from cStringIO import StringIO
+except ImportError:
+    from StringIO import StringIO
+
 from django.utils.importlib import import_module
 from django.utils.safestring import mark_safe, SafeData
 
diff --git a/django/utils/unittest/__init__.py b/django/utils/unittest/__init__.py
index ac852a3..ac007b9 100644
--- a/django/utils/unittest/__init__.py
+++ b/django/utils/unittest/__init__.py
@@ -52,21 +52,19 @@ except ImportError:
 
         from django.utils.unittest.collector import collector
         from django.utils.unittest.result import TestResult
-        from django.utils.unittest.case import \
-            TestCase, FunctionTestCase, SkipTest, skip, skipIf,\
-            skipUnless, expectedFailure
+        from django.utils.unittest.case import (TestCase, FunctionTestCase,
+            SkipTest, skip, skipIf, skipUnless, expectedFailure)
 
         from django.utils.unittest.suite import BaseTestSuite, TestSuite
-        from django.utils.unittest.loader import \
-            TestLoader, defaultTestLoader, makeSuite, getTestCaseNames,\
-            findTestCases
+        from django.utils.unittest.loader import (TestLoader, defaultTestLoader,
+            makeSuite, getTestCaseNames, findTestCases)
 
         from django.utils.unittest.main import TestProgram, main, main_
         from django.utils.unittest.runner import TextTestRunner, TextTestResult
 
         try:
-            from django.utils.unittest.signals import\
-                installHandler, registerResult, removeResult, removeHandler
+            from django.utils.unittest.signals import (installHandler,
+                registerResult, removeResult, removeHandler)
         except ImportError:
             # Compatibility with platforms that don't have the signal module
             pass
diff --git a/django/utils/unittest/case.py b/django/utils/unittest/case.py
index 78507c1..d81d666 100644
--- a/django/utils/unittest/case.py
+++ b/django/utils/unittest/case.py
@@ -12,7 +12,7 @@ from django.utils.unittest.util import\
     safe_repr, safe_str, strclass,\
     unorderable_list_difference
 
-from django.utils.unittest.compatibility import wraps
+from functools import wraps
 
 __unittest = True
 
diff --git a/django/utils/unittest/compatibility.py b/django/utils/unittest/compatibility.py
index a0dc499..b8d6397 100644
--- a/django/utils/unittest/compatibility.py
+++ b/django/utils/unittest/compatibility.py
@@ -1,14 +1,8 @@
 import os
 import sys
 
-try:
-    from functools import wraps
-except ImportError:
-    # only needed for Python 2.4
-    def wraps(_):
-        def _wraps(func):
-            return func
-        return _wraps
+# Backwards compatibility: Django used to re-define `wraps` for Python 2.4.
+from functools import wraps
 
 __unittest = True
 
diff --git a/django/utils/unittest/result.py b/django/utils/unittest/result.py
index 2d2a1ad..2b8fae2 100644
--- a/django/utils/unittest/result.py
+++ b/django/utils/unittest/result.py
@@ -3,11 +3,10 @@
 import sys
 import traceback
 import unittest
-
+from functools import wraps
 from StringIO import StringIO
 
 from django.utils.unittest import util
-from django.utils.unittest.compatibility import wraps
 
 __unittest = True
 
diff --git a/django/utils/unittest/signals.py b/django/utils/unittest/signals.py
index f1731ea..fc31043 100644
--- a/django/utils/unittest/signals.py
+++ b/django/utils/unittest/signals.py
@@ -1,7 +1,7 @@
 import signal
 import weakref
 
-from django.utils.unittest.compatibility import wraps
+from functools import wraps
 
 __unittest = True
 
diff --git a/django/utils/version.py b/django/utils/version.py
index 557135f..cb8623b 100644
--- a/django/utils/version.py
+++ b/django/utils/version.py
@@ -1,5 +1,4 @@
 import django
-import os.path
 import re
 
 def get_svn_revision(path=None):
diff --git a/django/views/debug.py b/django/views/debug.py
index 490d4bb..58d271b 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -3,7 +3,6 @@ import os
 import re
 import sys
 import types
-from pprint import pformat
 
 from django.conf import settings
 from django.http import (HttpResponse, HttpResponseServerError,
diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py
index 6fc882e..495a7b1 100644
--- a/django/views/decorators/http.py
+++ b/django/views/decorators/http.py
@@ -3,7 +3,6 @@ Decorators for views based on HTTP headers.
 """
 
 from calendar import timegm
-from datetime import timedelta
 from functools import wraps
 
 from django.utils.decorators import decorator_from_middleware, available_attrs
diff --git a/django/views/generic/base.py b/django/views/generic/base.py
index 6b52567..f2d4950 100644
--- a/django/views/generic/base.py
+++ b/django/views/generic/base.py
@@ -1,7 +1,6 @@
 from functools import update_wrapper
 from django import http
 from django.core.exceptions import ImproperlyConfigured
-from django.template import RequestContext, loader
 from django.template.response import TemplateResponse
 from django.utils.log import getLogger
 from django.utils.decorators import classonlymethod
diff --git a/django/views/generic/detail.py b/django/views/generic/detail.py
index 7e9047f..16e2c48 100644
--- a/django/views/generic/detail.py
+++ b/django/views/generic/detail.py
@@ -1,5 +1,3 @@
-import re
-
 from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
 from django.http import Http404
 from django.utils.encoding import smart_str
diff --git a/django/views/generic/list.py b/django/views/generic/list.py
index 5135763..9797356 100644
--- a/django/views/generic/list.py
+++ b/django/views/generic/list.py
@@ -1,5 +1,3 @@
-import re
-
 from django.core.paginator import Paginator, InvalidPage
 from django.core.exceptions import ImproperlyConfigured
 from django.http import Http404
diff --git a/tests/modeltests/basic/models.py b/tests/modeltests/basic/models.py
index 5f51fd8..26fddf0 100644
--- a/tests/modeltests/basic/models.py
+++ b/tests/modeltests/basic/models.py
@@ -4,7 +4,7 @@
 
 This is a basic model with only two non-primary-key fields.
 """
-from django.db import models, DEFAULT_DB_ALIAS, connection
+from django.db import models
 
 class Article(models.Model):
     headline = models.CharField(max_length=100, default='Default headline')
diff --git a/tests/modeltests/basic/tests.py b/tests/modeltests/basic/tests.py
index 966798d..ff09d9b 100644
--- a/tests/modeltests/basic/tests.py
+++ b/tests/modeltests/basic/tests.py
@@ -1,7 +1,6 @@
 from datetime import datetime
 
 from django.core.exceptions import ObjectDoesNotExist
-from django.db import models, DEFAULT_DB_ALIAS, connection
 from django.db.models.fields import FieldDoesNotExist
 from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
 
diff --git a/tests/modeltests/custom_pk/models.py b/tests/modeltests/custom_pk/models.py
index ff2f2ba..c514fd7 100644
--- a/tests/modeltests/custom_pk/models.py
+++ b/tests/modeltests/custom_pk/models.py
@@ -6,8 +6,7 @@ By default, Django adds an ``"id"`` field to each model. But you can override
 this behavior by explicitly adding ``primary_key=True`` to a field.
 """
 
-from django.conf import settings
-from django.db import models, transaction, IntegrityError, DEFAULT_DB_ALIAS
+from django.db import models
 
 from fields import MyAutoField
 
diff --git a/tests/modeltests/custom_pk/tests.py b/tests/modeltests/custom_pk/tests.py
index c410ad1..6b94b6d 100644
--- a/tests/modeltests/custom_pk/tests.py
+++ b/tests/modeltests/custom_pk/tests.py
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
-from django.conf import settings
-from django.db import DEFAULT_DB_ALIAS, transaction, IntegrityError
+from django.db import transaction, IntegrityError
 from django.test import TestCase, skipIfDBFeature
 
 from models import Employee, Business, Bar, Foo
diff --git a/tests/modeltests/delete/models.py b/tests/modeltests/delete/models.py
index ee9e999..f8b78eb 100644
--- a/tests/modeltests/delete/models.py
+++ b/tests/modeltests/delete/models.py
@@ -1,4 +1,4 @@
-from django.db import models, IntegrityError
+from django.db import models
 
 
 class R(models.Model):
diff --git a/tests/modeltests/field_subclassing/fields.py b/tests/modeltests/field_subclassing/fields.py
index 309648e..d6e4980 100644
--- a/tests/modeltests/field_subclassing/fields.py
+++ b/tests/modeltests/field_subclassing/fields.py
@@ -1,4 +1,3 @@
-from django.core.exceptions import FieldError
 from django.db import models
 from django.utils import simplejson as json
 from django.utils.encoding import force_unicode
diff --git a/tests/modeltests/field_subclassing/models.py b/tests/modeltests/field_subclassing/models.py
index b0d8336..c59c0d5 100644
--- a/tests/modeltests/field_subclassing/models.py
+++ b/tests/modeltests/field_subclassing/models.py
@@ -5,7 +5,7 @@ Tests for field subclassing.
 from django.db import models
 from django.utils.encoding import force_unicode
 
-from fields import Small, SmallField, SmallerField, JSONField
+from fields import SmallField, SmallerField, JSONField
 
 
 class MyModel(models.Model):
diff --git a/tests/modeltests/files/models.py b/tests/modeltests/files/models.py
index ca8965e..4134472 100644
--- a/tests/modeltests/files/models.py
+++ b/tests/modeltests/files/models.py
@@ -9,7 +9,6 @@ import random
 import tempfile
 
 from django.db import models
-from django.core.files.base import ContentFile
 from django.core.files.storage import FileSystemStorage
 
 
diff --git a/tests/modeltests/files/tests.py b/tests/modeltests/files/tests.py
index 885f787..e8e7a76 100644
--- a/tests/modeltests/files/tests.py
+++ b/tests/modeltests/files/tests.py
@@ -1,7 +1,6 @@
 from __future__ import with_statement
 
 import shutil
-import sys
 import tempfile
 
 from django.core.cache import cache
diff --git a/tests/modeltests/fixtures/models.py b/tests/modeltests/fixtures/models.py
index c8fd6a6..d2317d2 100644
--- a/tests/modeltests/fixtures/models.py
+++ b/tests/modeltests/fixtures/models.py
@@ -11,8 +11,7 @@ in the application directory, or in one of the directories named in the
 from django.contrib.auth.models import Permission
 from django.contrib.contenttypes import generic
 from django.contrib.contenttypes.models import ContentType
-from django.db import models, DEFAULT_DB_ALIAS
-from django.conf import settings
+from django.db import models
 
 
 class Category(models.Model):
diff --git a/tests/modeltests/fixtures/tests.py b/tests/modeltests/fixtures/tests.py
index 31f72f0..c335ffb 100644
--- a/tests/modeltests/fixtures/tests.py
+++ b/tests/modeltests/fixtures/tests.py
@@ -1,13 +1,10 @@
 import StringIO
-import sys
 
-from django.conf import settings
 from django.contrib.sites.models import Site
 from django.core import management
-from django.db import DEFAULT_DB_ALIAS
 from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
 
-from models import Article, Blog, Book, Category, Person, Spy, Tag, Visa
+from models import Article, Book, Spy, Tag, Visa
 
 
 class TestCaseFixtureLoadingTests(TestCase):
diff --git a/tests/modeltests/fixtures_model_package/models/__init__.py b/tests/modeltests/fixtures_model_package/models/__init__.py
index c0450b2..5cb0e4a 100644
--- a/tests/modeltests/fixtures_model_package/models/__init__.py
+++ b/tests/modeltests/fixtures_model_package/models/__init__.py
@@ -1,5 +1,4 @@
 from django.db import models
-from django.conf import settings
 
 class Article(models.Model):
     headline = models.CharField(max_length=100, default='Default headline')
diff --git a/tests/modeltests/force_insert_update/models.py b/tests/modeltests/force_insert_update/models.py
index 9516be7..e617aa2 100644
--- a/tests/modeltests/force_insert_update/models.py
+++ b/tests/modeltests/force_insert_update/models.py
@@ -2,7 +2,7 @@
 Tests for forcing insert and update queries (instead of Django's normal
 automatic behaviour).
 """
-from django.db import models, transaction, IntegrityError
+from django.db import models
 
 class Counter(models.Model):
     name = models.CharField(max_length = 10)
diff --git a/tests/modeltests/get_object_or_404/models.py b/tests/modeltests/get_object_or_404/models.py
index eb3cd82..f62dd0c 100644
--- a/tests/modeltests/get_object_or_404/models.py
+++ b/tests/modeltests/get_object_or_404/models.py
@@ -11,8 +11,6 @@ performing a ``filter()`` lookup and raising a ``Http404`` exception if a
 """
 
 from django.db import models
-from django.http import Http404
-from django.shortcuts import get_object_or_404, get_list_or_404
 
 class Author(models.Model):
     name = models.CharField(max_length=50)
diff --git a/tests/modeltests/get_or_create/models.py b/tests/modeltests/get_or_create/models.py
index db5719b..14f55f8 100644
--- a/tests/modeltests/get_or_create/models.py
+++ b/tests/modeltests/get_or_create/models.py
@@ -6,7 +6,7 @@ given parameters. If an object isn't found, it creates one with the given
 parameters.
 """
 
-from django.db import models, IntegrityError
+from django.db import models
 
 class Person(models.Model):
     first_name = models.CharField(max_length=100)
diff --git a/tests/modeltests/lookup/models.py b/tests/modeltests/lookup/models.py
index d807531..82434bb 100644
--- a/tests/modeltests/lookup/models.py
+++ b/tests/modeltests/lookup/models.py
@@ -4,8 +4,7 @@
 This demonstrates features of the database API.
 """
 
-from django.db import models, DEFAULT_DB_ALIAS, connection
-from django.conf import settings
+from django.db import models
 
 class Author(models.Model):
     name = models.CharField(max_length=100)
diff --git a/tests/modeltests/lookup/tests.py b/tests/modeltests/lookup/tests.py
index 3f40bf1..b05227c 100644
--- a/tests/modeltests/lookup/tests.py
+++ b/tests/modeltests/lookup/tests.py
@@ -1,7 +1,6 @@
 from datetime import datetime
 from operator import attrgetter
 from django.core.exceptions import FieldError
-from django.db import connection
 from django.test import TestCase, skipUnlessDBFeature
 from models import Author, Article, Tag
 
diff --git a/tests/modeltests/m2m_through/tests.py b/tests/modeltests/m2m_through/tests.py
index 807e952..814e54f 100644
--- a/tests/modeltests/m2m_through/tests.py
+++ b/tests/modeltests/m2m_through/tests.py
@@ -3,8 +3,8 @@ from operator import attrgetter
 
 from django.test import TestCase
 
-from models import Person, Group, Membership, CustomMembership, \
-    TestNoDefaultsOrNulls, PersonSelfRefM2M, Friendship
+from models import (Person, Group, Membership, CustomMembership,
+    PersonSelfRefM2M, Friendship)
 
 
 class M2mThroughTests(TestCase):
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
index 7204b28..5dcc039 100644
--- a/tests/modeltests/model_forms/models.py
+++ b/tests/modeltests/model_forms/models.py
@@ -7,7 +7,6 @@ and the examples are probably a poor fit for the ``ModelForm`` syntax. In other
 words, most of these tests should be rewritten.
 """
 
-import os
 import tempfile
 
 from django.db import models
diff --git a/tests/modeltests/model_formsets/tests.py b/tests/modeltests/model_formsets/tests.py
index 6303e6d..34f8d47 100644
--- a/tests/modeltests/model_formsets/tests.py
+++ b/tests/modeltests/model_formsets/tests.py
@@ -10,7 +10,7 @@ from django.forms.models import (_get_foreign_key, inlineformset_factory,
 from django.test import TestCase, skipUnlessDBFeature
 
 from modeltests.model_formsets.models import (
-    Author, BetterAuthor, Book, BookWithCustomPK, Editor,
+    Author, BetterAuthor, Book, BookWithCustomPK,
     BookWithOptionalAltEditor, AlternateBook, AuthorMeeting, CustomPrimaryKey,
     Place, Owner, Location, OwnerProfile, Restaurant, Product, Price,
     MexicanRestaurant, ClassyMexicanRestaurant, Repository, Revision,
diff --git a/tests/modeltests/mutually_referential/tests.py b/tests/modeltests/mutually_referential/tests.py
index 101d67c..365c741 100644
--- a/tests/modeltests/mutually_referential/tests.py
+++ b/tests/modeltests/mutually_referential/tests.py
@@ -1,5 +1,5 @@
 from django.test import TestCase
-from models import Parent, Child
+from models import Parent
 
 class MutuallyReferentialTests(TestCase):
 
diff --git a/tests/modeltests/one_to_one/models.py b/tests/modeltests/one_to_one/models.py
index f263735..246c3fc 100644
--- a/tests/modeltests/one_to_one/models.py
+++ b/tests/modeltests/one_to_one/models.py
@@ -6,7 +6,7 @@ To define a one-to-one relationship, use ``OneToOneField()``.
 In this example, a ``Place`` optionally can be a ``Restaurant``.
 """
 
-from django.db import models, transaction, IntegrityError
+from django.db import models
 
 class Place(models.Model):
     name = models.CharField(max_length=50)
diff --git a/tests/modeltests/pagination/tests.py b/tests/modeltests/pagination/tests.py
index eaee466..1129052 100644
--- a/tests/modeltests/pagination/tests.py
+++ b/tests/modeltests/pagination/tests.py
@@ -1,5 +1,4 @@
 from datetime import datetime
-from operator import attrgetter
 
 from django.core.paginator import Paginator, InvalidPage, EmptyPage
 from django.test import TestCase
diff --git a/tests/modeltests/proxy_model_inheritance/tests.py b/tests/modeltests/proxy_model_inheritance/tests.py
index 7426f41..546c507 100644
--- a/tests/modeltests/proxy_model_inheritance/tests.py
+++ b/tests/modeltests/proxy_model_inheritance/tests.py
@@ -9,7 +9,7 @@ apps and calls syncdb, then verifies that the table has been created.
 import os
 import sys
 
-from django.conf import settings, Settings
+from django.conf import settings
 from django.core.management import call_command
 from django.db.models.loading import load_app
 from django.test import TransactionTestCase
diff --git a/tests/modeltests/proxy_models/models.py b/tests/modeltests/proxy_models/models.py
index 90d54d9..4fc9c6d 100644
--- a/tests/modeltests/proxy_models/models.py
+++ b/tests/modeltests/proxy_models/models.py
@@ -5,7 +5,6 @@ than using a new table of their own. This allows them to act as simple proxies,
 providing a modified interface to the data from the base class.
 """
 
-from django.contrib.contenttypes.models import ContentType
 from django.db import models
 
 
diff --git a/tests/modeltests/serializers/tests.py b/tests/modeltests/serializers/tests.py
index 013438e..bd528fc 100644
--- a/tests/modeltests/serializers/tests.py
+++ b/tests/modeltests/serializers/tests.py
@@ -9,8 +9,7 @@ from django.db import transaction
 from django.test import TestCase, TransactionTestCase, Approximate
 from django.utils import simplejson, unittest
 
-from models import Category, Author, Article, AuthorProfile, Actor, \
-                                    Movie, Score, Player, Team
+from models import Category, Author, Article, AuthorProfile, Actor, Movie, Score, Player, Team
 
 class SerializerRegistrationTests(unittest.TestCase):
     def setUp(self):
diff --git a/tests/modeltests/transactions/models.py b/tests/modeltests/transactions/models.py
index d957fe1..b2ae396 100644
--- a/tests/modeltests/transactions/models.py
+++ b/tests/modeltests/transactions/models.py
@@ -7,7 +7,7 @@ commit-on-success behavior. Alternatively, you can manage the transaction
 manually.
 """
 
-from django.db import models, DEFAULT_DB_ALIAS
+from django.db import models
 
 class Reporter(models.Model):
     first_name = models.CharField(max_length=30)
diff --git a/tests/modeltests/transactions/tests.py b/tests/modeltests/transactions/tests.py
index db58b80..5cebe67 100644
--- a/tests/modeltests/transactions/tests.py
+++ b/tests/modeltests/transactions/tests.py
@@ -1,9 +1,6 @@
 from __future__ import with_statement
 
-import sys
-
-from django.db import connection, transaction, IntegrityError, DEFAULT_DB_ALIAS
-from django.conf import settings
+from django.db import connection, transaction, IntegrityError
 from django.test import TransactionTestCase, skipUnlessDBFeature
 
 from models import Reporter
diff --git a/tests/modeltests/unmanaged_models/tests.py b/tests/modeltests/unmanaged_models/tests.py
index dee3799..b9817ef 100644
--- a/tests/modeltests/unmanaged_models/tests.py
+++ b/tests/modeltests/unmanaged_models/tests.py
@@ -1,7 +1,6 @@
 from django.test import TestCase
 from django.db import connection
-from models import Unmanaged1, Unmanaged2, Managed1
-from models import A01, A02, B01, B02, C01, C02
+from models import A01, A02, B01, B02, C01, C02, Unmanaged2, Managed1
 
 class SimpleTests(TestCase):
 
diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py
index f92fc1f..52e1f97 100644
--- a/tests/modeltests/validation/models.py
+++ b/tests/modeltests/validation/models.py
@@ -1,7 +1,6 @@
 from datetime import datetime
 from django.core.exceptions import ValidationError
 from django.db import models
-from django.test import TestCase
 
 
 def validate_answer_to_universe(value):
diff --git a/tests/modeltests/validation/validators.py b/tests/modeltests/validation/validators.py
index 6a7d833..30ce661 100644
--- a/tests/modeltests/validation/validators.py
+++ b/tests/modeltests/validation/validators.py
@@ -1,5 +1,3 @@
-from django.utils.unittest import TestCase
-
 from modeltests.validation import ValidationTestCase
 from models import *
 
diff --git a/tests/regressiontests/admin_filters/tests.py b/tests/regressiontests/admin_filters/tests.py
index 5095abb..b4c4f34 100644
--- a/tests/regressiontests/admin_filters/tests.py
+++ b/tests/regressiontests/admin_filters/tests.py
@@ -1,5 +1,3 @@
-from __future__ import with_statement
-
 import datetime
 
 from django.core.exceptions import ImproperlyConfigured
diff --git a/tests/regressiontests/admin_validation/tests.py b/tests/regressiontests/admin_validation/tests.py
index 2cf3c60..ef391ff 100644
--- a/tests/regressiontests/admin_validation/tests.py
+++ b/tests/regressiontests/admin_validation/tests.py
@@ -1,7 +1,6 @@
 from django.contrib import admin
 from django import forms
-from django.contrib.admin.validation import validate, validate_inline, \
-                                            ImproperlyConfigured
+from django.contrib.admin.validation import validate, validate_inline, ImproperlyConfigured
 from django.test import TestCase
 
 from models import Song, Book, Album, TwoAlbumFKAndAnE, State, City
diff --git a/tests/regressiontests/bash_completion/management/commands/test_command.py b/tests/regressiontests/bash_completion/management/commands/test_command.py
index 5cb8820..0f57506 100644
--- a/tests/regressiontests/bash_completion/management/commands/test_command.py
+++ b/tests/regressiontests/bash_completion/management/commands/test_command.py
@@ -1,5 +1,4 @@
-import sys, os
-from optparse import OptionParser, make_option
+from optparse import make_option
 
 from django.core.management.base import BaseCommand
 
diff --git a/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py b/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py
index 4177163..9d6a9e7 100644
--- a/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py
+++ b/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py
@@ -1,5 +1,4 @@
-from regressiontests.comment_tests.tests import CommentTestCase, CT, Site
-from django.contrib.comments.forms import CommentForm
+from regressiontests.comment_tests.tests import CommentTestCase
 from django.contrib.comments.models import Comment
 from django.contrib.comments.moderation import moderator, CommentModerator, AlreadyModerated
 from regressiontests.comment_tests.models import Entry
diff --git a/tests/regressiontests/comment_tests/tests/feed_tests.py b/tests/regressiontests/comment_tests/tests/feed_tests.py
index 2dccbcd..4497f95 100644
--- a/tests/regressiontests/comment_tests/tests/feed_tests.py
+++ b/tests/regressiontests/comment_tests/tests/feed_tests.py
@@ -1,7 +1,3 @@
-import warnings
-
-from django.test.utils import get_warnings_state, restore_warnings_state
-
 from regressiontests.comment_tests.tests import CommentTestCase
 
 
diff --git a/tests/regressiontests/comment_tests/tests/templatetag_tests.py b/tests/regressiontests/comment_tests/tests/templatetag_tests.py
index 0ead6c2..0ee34ac 100644
--- a/tests/regressiontests/comment_tests/tests/templatetag_tests.py
+++ b/tests/regressiontests/comment_tests/tests/templatetag_tests.py
@@ -1,5 +1,4 @@
 from django.contrib.comments.forms import CommentForm
-from django.contrib.comments.models import Comment
 from django.contrib.contenttypes.models import ContentType
 from django.template import Template, Context
 from regressiontests.comment_tests.models import Article, Author
diff --git a/tests/regressiontests/csrf_tests/tests.py b/tests/regressiontests/csrf_tests/tests.py
index b3238a7..c5f9f36 100644
--- a/tests/regressiontests/csrf_tests/tests.py
+++ b/tests/regressiontests/csrf_tests/tests.py
@@ -1,6 +1,5 @@
 # -*- coding: utf-8 -*-
 from __future__ import with_statement
-import warnings
 
 from django.test import TestCase
 from django.http import HttpRequest, HttpResponse
diff --git a/tests/regressiontests/datatypes/tests.py b/tests/regressiontests/datatypes/tests.py
index e161be9..2d40fec 100644
--- a/tests/regressiontests/datatypes/tests.py
+++ b/tests/regressiontests/datatypes/tests.py
@@ -1,7 +1,5 @@
 import datetime
 
-from django.conf import settings
-from django.db import DEFAULT_DB_ALIAS
 from django.test import TestCase, skipIfDBFeature
 from django.utils import tzinfo
 
diff --git a/tests/regressiontests/defer_regress/models.py b/tests/regressiontests/defer_regress/models.py
index 4e4ab0a..1d1a224 100644
--- a/tests/regressiontests/defer_regress/models.py
+++ b/tests/regressiontests/defer_regress/models.py
@@ -2,9 +2,7 @@
 Regression tests for defer() / only() behavior.
 """
 
-from django.conf import settings
-from django.contrib.contenttypes.models import ContentType
-from django.db import connection, models
+from django.db import models
 
 class Item(models.Model):
     name = models.CharField(max_length=15)
diff --git a/tests/regressiontests/defer_regress/tests.py b/tests/regressiontests/defer_regress/tests.py
index fbcf85e..2135522 100644
--- a/tests/regressiontests/defer_regress/tests.py
+++ b/tests/regressiontests/defer_regress/tests.py
@@ -1,9 +1,7 @@
 from operator import attrgetter
 
-from django.conf import settings
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.sessions.backends.db import SessionStore
-from django.db import connection
 from django.db.models.loading import cache
 from django.test import TestCase
 
diff --git a/tests/regressiontests/delete_regress/tests.py b/tests/regressiontests/delete_regress/tests.py
index ec26676..22b4833 100644
--- a/tests/regressiontests/delete_regress/tests.py
+++ b/tests/regressiontests/delete_regress/tests.py
@@ -1,11 +1,11 @@
 import datetime
 
 from django.conf import settings
-from django.db import backend, connection, transaction, DEFAULT_DB_ALIAS
+from django.db import backend, transaction, DEFAULT_DB_ALIAS
 from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
 
 from models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith,
-    PlayedWithNote, Contact, Email, Researcher, Food, Eaten,
+    PlayedWithNote, Email, Researcher, Food, Eaten,
     Policy, Version, Location, Item)
 
 
diff --git a/tests/regressiontests/expressions_regress/tests.py b/tests/regressiontests/expressions_regress/tests.py
index a900c6c..497a843 100644
--- a/tests/regressiontests/expressions_regress/tests.py
+++ b/tests/regressiontests/expressions_regress/tests.py
@@ -3,8 +3,7 @@ Spanning tests for all the operations that F() expressions can perform.
 """
 import datetime
 
-from django.conf import settings
-from django.db import models, connection
+from django.db import connection
 from django.db.models import F
 from django.test import TestCase, Approximate, skipUnlessDBFeature
 
diff --git a/tests/regressiontests/extra_regress/tests.py b/tests/regressiontests/extra_regress/tests.py
index ef7cbb8..5f779be 100644
--- a/tests/regressiontests/extra_regress/tests.py
+++ b/tests/regressiontests/extra_regress/tests.py
@@ -3,8 +3,7 @@ from django.test import TestCase
 from django.utils.datastructures import SortedDict
 
 from django.contrib.auth.models import User
-from regressiontests.extra_regress.models import TestObject, Order, \
-        RevisionableModel
+from regressiontests.extra_regress.models import TestObject, Order, RevisionableModel
 
 import datetime
 
diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py
index 917d2f3..40710eb 100644
--- a/tests/regressiontests/file_storage/tests.py
+++ b/tests/regressiontests/file_storage/tests.py
@@ -18,7 +18,7 @@ except ImportError:
 
 from django.conf import settings
 from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
-from django.core.files.base import ContentFile, File
+from django.core.files.base import ContentFile
 from django.core.files.images import get_image_dimensions
 from django.core.files.storage import FileSystemStorage, get_storage_class
 from django.core.files.uploadedfile import UploadedFile
diff --git a/tests/regressiontests/fixtures_regress/models.py b/tests/regressiontests/fixtures_regress/models.py
index 2dfb550..b353f80 100644
--- a/tests/regressiontests/fixtures_regress/models.py
+++ b/tests/regressiontests/fixtures_regress/models.py
@@ -1,6 +1,5 @@
-from django.db import models, DEFAULT_DB_ALIAS, connection
+from django.db import models
 from django.contrib.auth.models import User
-from django.conf import settings
 
 
 class Animal(models.Model):
diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py
index 3dc4ede..a565ec9 100644
--- a/tests/regressiontests/fixtures_regress/tests.py
+++ b/tests/regressiontests/fixtures_regress/tests.py
@@ -2,7 +2,6 @@
 # Unittests for fixtures.
 import os
 import re
-import sys
 try:
     from cStringIO import StringIO
 except ImportError:
@@ -13,8 +12,8 @@ from django.core.management.commands.dumpdata import sort_dependencies
 from django.core.management.base import CommandError
 from django.db.models import signals
 from django.db import transaction
-from django.test import TestCase, TransactionTestCase, skipIfDBFeature, \
-    skipUnlessDBFeature
+from django.test import (TestCase, TransactionTestCase, skipIfDBFeature,
+    skipUnlessDBFeature)
 
 from models import Animal, Stuff
 from models import Absolute, Parent, Child
diff --git a/tests/regressiontests/forms/localflavor/cl.py b/tests/regressiontests/forms/localflavor/cl.py
index b2b4562..59e4824 100644
--- a/tests/regressiontests/forms/localflavor/cl.py
+++ b/tests/regressiontests/forms/localflavor/cl.py
@@ -1,5 +1,4 @@
 from django.contrib.localflavor.cl.forms import CLRutField, CLRegionSelect
-from django.core.exceptions import ValidationError
 
 from utils import LocalFlavorTestCase
 
diff --git a/tests/regressiontests/forms/tests/fields.py b/tests/regressiontests/forms/tests/fields.py
index ad8d1d9..152a13e 100644
--- a/tests/regressiontests/forms/tests/fields.py
+++ b/tests/regressiontests/forms/tests/fields.py
@@ -25,7 +25,6 @@ Other than that, the Field subclasses have class-specific options for
 __init__(). For example, CharField has a max_length option.
 """
 import datetime
-import time
 import re
 import os
 import urllib2
@@ -33,7 +32,6 @@ from decimal import Decimal
 
 from django.core.files.uploadedfile import SimpleUploadedFile
 from django.forms import *
-from django.forms.widgets import RadioFieldRenderer
 from django.utils.unittest import TestCase
 
 
diff --git a/tests/regressiontests/forms/tests/forms.py b/tests/regressiontests/forms/tests/forms.py
index 91a7472..ce4004e 100644
--- a/tests/regressiontests/forms/tests/forms.py
+++ b/tests/regressiontests/forms/tests/forms.py
@@ -1,8 +1,5 @@
 # -*- coding: utf-8 -*-
 import datetime
-from decimal import Decimal
-import re
-import time
 from django.core.files.uploadedfile import SimpleUploadedFile
 from django.forms import *
 from django.http import QueryDict
diff --git a/tests/regressiontests/forms/tests/models.py b/tests/regressiontests/forms/tests/models.py
index 3f548df..5e1bd82 100644
--- a/tests/regressiontests/forms/tests/models.py
+++ b/tests/regressiontests/forms/tests/models.py
@@ -3,7 +3,8 @@ import datetime
 from django.core.files.uploadedfile import SimpleUploadedFile
 from django.forms import Form, ModelForm, FileField, ModelChoiceField
 from django.test import TestCase
-from regressiontests.forms.models import ChoiceModel, ChoiceOptionModel, ChoiceFieldModel, FileModel, Group, BoundaryModel, Defaults
+from regressiontests.forms.models import (ChoiceOptionModel, ChoiceFieldModel,
+    FileModel, Group, BoundaryModel, Defaults)
 
 
 class ChoiceFieldForm(ModelForm):
diff --git a/tests/regressiontests/forms/tests/widgets.py b/tests/regressiontests/forms/tests/widgets.py
index 0a8a879..b4ceb2f 100644
--- a/tests/regressiontests/forms/tests/widgets.py
+++ b/tests/regressiontests/forms/tests/widgets.py
@@ -2,9 +2,6 @@
 
 import copy
 import datetime
-import re
-import time
-from decimal import Decimal
 from django.conf import settings
 from django.core.files.uploadedfile import SimpleUploadedFile
 from django.forms import *
diff --git a/tests/regressiontests/generic_inline_admin/tests.py b/tests/regressiontests/generic_inline_admin/tests.py
index c40b6dd..b037ebe 100644
--- a/tests/regressiontests/generic_inline_admin/tests.py
+++ b/tests/regressiontests/generic_inline_admin/tests.py
@@ -5,8 +5,8 @@ from django.contrib.contenttypes.generic import generic_inlineformset_factory
 from django.test import TestCase
 
 # local test models
-from models import Episode, EpisodeExtra, EpisodeMaxNum, EpisodeExclude, \
-                   Media, EpisodePermanent, MediaPermanentInline, Category
+from models import (Episode, EpisodeExtra, EpisodeMaxNum, EpisodeExclude,
+    Media, EpisodePermanent, MediaPermanentInline, Category)
 
 
 class GenericAdminViewTest(TestCase):
diff --git a/tests/regressiontests/generic_relations_regress/tests.py b/tests/regressiontests/generic_relations_regress/tests.py
index 45e8674..52731a9 100644
--- a/tests/regressiontests/generic_relations_regress/tests.py
+++ b/tests/regressiontests/generic_relations_regress/tests.py
@@ -1,5 +1,4 @@
 from django.test import TestCase
-from django.contrib.contenttypes.models import ContentType
 from django.db.models import Q
 from models import *
 
diff --git a/tests/regressiontests/generic_views/base.py b/tests/regressiontests/generic_views/base.py
index fc5cf62..40490a4 100644
--- a/tests/regressiontests/generic_views/base.py
+++ b/tests/regressiontests/generic_views/base.py
@@ -4,7 +4,6 @@ import unittest
 from django.core.exceptions import ImproperlyConfigured
 from django.http import HttpResponse
 from django.test import TestCase, RequestFactory
-from django.utils import simplejson
 from django.views.generic import View, TemplateView, RedirectView
 
 
diff --git a/tests/regressiontests/generic_views/dates.py b/tests/regressiontests/generic_views/dates.py
index 5b784f6..b9608d6 100644
--- a/tests/regressiontests/generic_views/dates.py
+++ b/tests/regressiontests/generic_views/dates.py
@@ -1,5 +1,4 @@
 import datetime
-import random
 
 from django.core.exceptions import ImproperlyConfigured
 from django.test import TestCase
diff --git a/tests/regressiontests/generic_views/list.py b/tests/regressiontests/generic_views/list.py
index c41680c..f5bf910 100644
--- a/tests/regressiontests/generic_views/list.py
+++ b/tests/regressiontests/generic_views/list.py
@@ -2,7 +2,6 @@ from django.core.exceptions import ImproperlyConfigured
 from django.test import TestCase
 
 from regressiontests.generic_views.models import Author, Artist
-from regressiontests.generic_views.views import CustomPaginator
 
 class ListViewTests(TestCase):
     fixtures = ['generic-views-test-data.json']
diff --git a/tests/regressiontests/i18n/forms.py b/tests/regressiontests/i18n/forms.py
index 156441c..600f252 100644
--- a/tests/regressiontests/i18n/forms.py
+++ b/tests/regressiontests/i18n/forms.py
@@ -1,5 +1,6 @@
-from django import template, forms
+from django import forms
 from django.forms.extras import SelectDateWidget
+
 from models import Company
 
 class I18nForm(forms.Form):
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index e3add3e..194825f 100644
--- a/tests/regressiontests/i18n/tests.py
+++ b/tests/regressiontests/i18n/tests.py
@@ -3,7 +3,6 @@ from __future__ import with_statement
 import datetime
 import decimal
 import os
-import sys
 import pickle
 from threading import local
 
diff --git a/tests/regressiontests/introspection/tests.py b/tests/regressiontests/introspection/tests.py
index e309a98..4f5fb09 100644
--- a/tests/regressiontests/introspection/tests.py
+++ b/tests/regressiontests/introspection/tests.py
@@ -1,6 +1,5 @@
 from functools import update_wrapper
-from django.conf import settings
-from django.db import connection, DEFAULT_DB_ALIAS
+from django.db import connection
 from django.test import TestCase, skipUnlessDBFeature
 
 from models import Reporter, Article
diff --git a/tests/regressiontests/localflavor/tests.py b/tests/regressiontests/localflavor/tests.py
index 6a02d99..6a15d46 100644
--- a/tests/regressiontests/localflavor/tests.py
+++ b/tests/regressiontests/localflavor/tests.py
@@ -1,7 +1,3 @@
-from django.test import TestCase
-from django.utils import unittest
-
-# just import your tests here
 from au.tests import *
 from mk.tests import *
 from us.tests import *
diff --git a/tests/regressiontests/m2m_through_regress/models.py b/tests/regressiontests/m2m_through_regress/models.py
index 121ef22..ff71348 100644
--- a/tests/regressiontests/m2m_through_regress/models.py
+++ b/tests/regressiontests/m2m_through_regress/models.py
@@ -1,7 +1,4 @@
-from datetime import datetime
-
 from django.contrib.auth.models import User
-from django.core import management
 from django.db import models
 
 
diff --git a/tests/regressiontests/max_lengths/tests.py b/tests/regressiontests/max_lengths/tests.py
index 59d98d6..f743378 100644
--- a/tests/regressiontests/max_lengths/tests.py
+++ b/tests/regressiontests/max_lengths/tests.py
@@ -1,4 +1,3 @@
-from django.db import DatabaseError
 from django.utils import unittest
 from regressiontests.max_lengths.models import PersonWithDefaultMaxLengths, PersonWithCustomMaxLengths
 
diff --git a/tests/regressiontests/middleware_exceptions/models.py b/tests/regressiontests/middleware_exceptions/models.py
index 137941f..e69de29 100644
--- a/tests/regressiontests/middleware_exceptions/models.py
+++ b/tests/regressiontests/middleware_exceptions/models.py
@@ -1 +0,0 @@
-from django.db import models
diff --git a/tests/regressiontests/model_fields/imagefield.py b/tests/regressiontests/model_fields/imagefield.py
index dd79e7a..c952aa9 100644
--- a/tests/regressiontests/model_fields/imagefield.py
+++ b/tests/regressiontests/model_fields/imagefield.py
@@ -2,12 +2,11 @@ import os
 import shutil
 
 from django.core.files import File
-from django.core.files.base import ContentFile
 from django.core.files.images import ImageFile
 from django.test import TestCase
 
-from models import Image, Person, PersonWithHeight, PersonWithHeightAndWidth, \
-        PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile
+from models import (Image, Person, PersonWithHeight, PersonWithHeightAndWidth,
+        PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile)
 
 
 # If PIL available, do these tests.
diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
index b42c0af..3e9d614 100644
--- a/tests/regressiontests/model_fields/tests.py
+++ b/tests/regressiontests/model_fields/tests.py
@@ -12,14 +12,14 @@ from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanM
 
 # If PIL available, do these tests.
 if Image:
-    from imagefield import \
-            ImageFieldTests, \
-            ImageFieldTwoDimensionsTests, \
-            ImageFieldNoDimensionsTests, \
-            ImageFieldOneDimensionTests, \
-            ImageFieldDimensionsFirstTests, \
-            ImageFieldUsingFileTests, \
-            TwoImageFieldTests
+    from imagefield import (
+            ImageFieldTests,
+            ImageFieldTwoDimensionsTests,
+            ImageFieldNoDimensionsTests,
+            ImageFieldOneDimensionTests,
+            ImageFieldDimensionsFirstTests,
+            ImageFieldUsingFileTests,
+            TwoImageFieldTests)
 
 
 class BasicFieldTests(test.TestCase):
diff --git a/tests/regressiontests/model_forms_regress/tests.py b/tests/regressiontests/model_forms_regress/tests.py
index 9817858..9860c2e 100644
--- a/tests/regressiontests/model_forms_regress/tests.py
+++ b/tests/regressiontests/model_forms_regress/tests.py
@@ -8,8 +8,8 @@ from django.forms.models import (modelform_factory, ModelChoiceField,
 from django.utils import unittest
 from django.test import TestCase
 
-from models import Person, RealPerson, Triple, FilePathModel, Article, \
-    Publication, CustomFF, Author, Author1, Homepage, Document, Edition
+from models import (Person, RealPerson, Triple, FilePathModel, Article,
+    Publication, CustomFF, Author, Author1, Homepage, Document, Edition)
 
 
 class ModelMultipleChoiceFieldTests(TestCase):
diff --git a/tests/regressiontests/modeladmin/models.py b/tests/regressiontests/modeladmin/models.py
index 26eaaae..ae180a4 100644
--- a/tests/regressiontests/modeladmin/models.py
+++ b/tests/regressiontests/modeladmin/models.py
@@ -1,6 +1,4 @@
 # coding: utf-8
-from datetime import date
-
 from django.db import models
 from django.contrib.auth.models import User
 
diff --git a/tests/regressiontests/multiple_database/models.py b/tests/regressiontests/multiple_database/models.py
index ce71828..8146c57 100644
--- a/tests/regressiontests/multiple_database/models.py
+++ b/tests/regressiontests/multiple_database/models.py
@@ -1,4 +1,3 @@
-from django.conf import settings
 from django.contrib.auth.models import User
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes import generic
diff --git a/tests/regressiontests/multiple_database/tests.py b/tests/regressiontests/multiple_database/tests.py
index 551a677..74b928a 100644
--- a/tests/regressiontests/multiple_database/tests.py
+++ b/tests/regressiontests/multiple_database/tests.py
@@ -1,6 +1,5 @@
 import datetime
 import pickle
-import sys
 from StringIO import StringIO
 
 from django.conf import settings
@@ -8,7 +7,6 @@ from django.contrib.auth.models import User
 from django.core import management
 from django.db import connections, router, DEFAULT_DB_ALIAS
 from django.db.models import signals
-from django.db.utils import ConnectionRouter
 from django.test import TestCase
 
 from models import Book, Person, Pet, Review, UserProfile
diff --git a/tests/regressiontests/select_related_onetoone/tests.py b/tests/regressiontests/select_related_onetoone/tests.py
index ab35fec..3e7023a 100644
--- a/tests/regressiontests/select_related_onetoone/tests.py
+++ b/tests/regressiontests/select_related_onetoone/tests.py
@@ -1,5 +1,3 @@
-from django import db
-from django.conf import settings
 from django.test import TestCase
 
 from models import (User, UserProfile, UserStat, UserStatResult, StatDetails,
diff --git a/tests/regressiontests/serializers_regress/tests.py b/tests/regressiontests/serializers_regress/tests.py
index 90a438c..cd2ce3c 100644
--- a/tests/regressiontests/serializers_regress/tests.py
+++ b/tests/regressiontests/serializers_regress/tests.py
@@ -15,10 +15,9 @@ try:
 except ImportError:
     from StringIO import StringIO
 
-from django.conf import settings
-from django.core import serializers, management
+from django.core import serializers
 from django.core.serializers import SerializerDoesNotExist
-from django.db import transaction, DEFAULT_DB_ALIAS, connection
+from django.db import connection
 from django.test import TestCase
 from django.utils.functional import curry
 
diff --git a/tests/regressiontests/signals_regress/tests.py b/tests/regressiontests/signals_regress/tests.py
index 630b16f..332f5d9 100644
--- a/tests/regressiontests/signals_regress/tests.py
+++ b/tests/regressiontests/signals_regress/tests.py
@@ -1,5 +1,3 @@
-import sys
-from StringIO import StringIO
 from django.test import TestCase
 
 from django.db import models
diff --git a/tests/regressiontests/syndication/tests.py b/tests/regressiontests/syndication/tests.py
index 2f90dc0..6643298 100644
--- a/tests/regressiontests/syndication/tests.py
+++ b/tests/regressiontests/syndication/tests.py
@@ -1,5 +1,3 @@
-import datetime
-import warnings
 from xml.dom import minidom
 
 from django.contrib.syndication import views
diff --git a/tests/regressiontests/templates/custom.py b/tests/regressiontests/templates/custom.py
index 74c39ab..d781874 100644
--- a/tests/regressiontests/templates/custom.py
+++ b/tests/regressiontests/templates/custom.py
@@ -1,5 +1,3 @@
-from __future__ import with_statement
-
 from django import template
 from django.utils.unittest import TestCase
 from templatetags import custom
diff --git a/tests/regressiontests/templates/loaders.py b/tests/regressiontests/templates/loaders.py
index 1773592..c2ae0bd 100644
--- a/tests/regressiontests/templates/loaders.py
+++ b/tests/regressiontests/templates/loaders.py
@@ -14,12 +14,10 @@ import pkg_resources
 import imp
 import StringIO
 import os.path
-import warnings
 
 from django.template import TemplateDoesNotExist, Context
 from django.template.loaders.eggs import Loader as EggLoader
 from django.template import loader
-from django.test.utils import get_warnings_state, restore_warnings_state
 from django.utils import unittest
 
 
diff --git a/tests/regressiontests/templates/response.py b/tests/regressiontests/templates/response.py
index 6fc2ded..a1257fe 100644
--- a/tests/regressiontests/templates/response.py
+++ b/tests/regressiontests/templates/response.py
@@ -6,7 +6,7 @@ from django.utils import unittest
 from django.test import RequestFactory, TestCase
 from django.conf import settings
 import django.template.context
-from django.template import Template, Context, RequestContext
+from django.template import Template, Context
 from django.template.response import (TemplateResponse, SimpleTemplateResponse,
                                       ContentNotRenderedError)
 
diff --git a/tests/regressiontests/templates/smartif.py b/tests/regressiontests/templates/smartif.py
index 2ce2df3..3a705ca 100644
--- a/tests/regressiontests/templates/smartif.py
+++ b/tests/regressiontests/templates/smartif.py
@@ -1,4 +1,4 @@
-from django.template.smartif import IfParser, Literal
+from django.template.smartif import IfParser
 from django.utils import unittest
 
 class SmartIfTests(unittest.TestCase):
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 36a1ca3..4ed7c53 100644
--- a/tests/regressiontests/templates/tests.py
+++ b/tests/regressiontests/templates/tests.py
@@ -14,12 +14,12 @@ import traceback
 import warnings
 
 from django import template
-from django.template import base as template_base
+from django.template import base as template_base, RequestContext
 from django.core import urlresolvers
 from django.template import loader
 from django.template.loaders import app_directories, filesystem, cached
-from django.test.utils import get_warnings_state, restore_warnings_state,\
-    setup_test_template_loader, restore_template_loaders
+from django.test.utils import (get_warnings_state, restore_warnings_state,
+    setup_test_template_loader, restore_template_loaders)
 from django.utils import unittest
 from django.utils.formats import date_format
 from django.utils.translation import activate, deactivate, ugettext as _
diff --git a/tests/regressiontests/test_utils/tests.py b/tests/regressiontests/test_utils/tests.py
index 673295b..a35b0bc 100644
--- a/tests/regressiontests/test_utils/tests.py
+++ b/tests/regressiontests/test_utils/tests.py
@@ -1,8 +1,6 @@
 from __future__ import with_statement
 
-import sys
-
-from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
+from django.test import TestCase, skipUnlessDBFeature
 from django.utils.unittest import skip
 
 from models import Person
diff --git a/tests/regressiontests/urlpatterns_reverse/middleware.py b/tests/regressiontests/urlpatterns_reverse/middleware.py
index cd3c045..7bc42f8 100644
--- a/tests/regressiontests/urlpatterns_reverse/middleware.py
+++ b/tests/regressiontests/urlpatterns_reverse/middleware.py
@@ -1,5 +1,3 @@
-from django.core.urlresolvers import set_urlconf
-
 import urlconf_inner
 
 class ChangeURLconfMiddleware(object):
diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py
index 31a928c..3db14d3 100644
--- a/tests/regressiontests/urlpatterns_reverse/tests.py
+++ b/tests/regressiontests/urlpatterns_reverse/tests.py
@@ -3,9 +3,8 @@ Unit tests for reverse URL lookups.
 """
 from django.conf import settings
 from django.core.exceptions import ImproperlyConfigured
-from django.core.urlresolvers import reverse, resolve, NoReverseMatch,\
-                                     Resolver404, ResolverMatch,\
-                                     RegexURLResolver, RegexURLPattern
+from django.core.urlresolvers import (reverse, resolve, NoReverseMatch,
+    Resolver404, ResolverMatch, RegexURLResolver, RegexURLPattern)
 from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect
 from django.shortcuts import redirect
 from django.test import TestCase
diff --git a/tests/regressiontests/utils/jslex.py b/tests/regressiontests/utils/jslex.py
index 08e8386..7cd93ca 100644
--- a/tests/regressiontests/utils/jslex.py
+++ b/tests/regressiontests/utils/jslex.py
@@ -2,7 +2,6 @@
 # encoding: utf-8
 # originally from https://bitbucket.org/ned/jslex
 
-import difflib
 from django.test import TestCase
 from django.utils.jslex import JsLexer, prepare_js_for_gettext
 
diff --git a/tests/regressiontests/views/tests/debug.py b/tests/regressiontests/views/tests/debug.py
index 1dbaff4..ac12fbd 100644
--- a/tests/regressiontests/views/tests/debug.py
+++ b/tests/regressiontests/views/tests/debug.py
@@ -9,7 +9,6 @@ from django.test import TestCase, RequestFactory
 from django.core.urlresolvers import reverse
 from django.template import TemplateSyntaxError
 from django.views.debug import ExceptionReporter
-from django.core.exceptions import ImproperlyConfigured
 from django.core import mail
 
 from regressiontests.views import BrokenException, except_args
diff --git a/tests/regressiontests/views/tests/defaults.py b/tests/regressiontests/views/tests/defaults.py
index c7c295a..6378cf9 100644
--- a/tests/regressiontests/views/tests/defaults.py
+++ b/tests/regressiontests/views/tests/defaults.py
@@ -1,6 +1,3 @@
-from os import path
-
-from django.conf import settings
 from django.test import TestCase
 from django.contrib.contenttypes.models import ContentType
 
