diff --git a/django/db/models/__init__.py b/django/db/models/__init__.py index 0abd97c60c..9e359f34ed 100644 --- a/django/db/models/__init__.py +++ b/django/db/models/__init__.py @@ -1,29 +1,21 @@ from django.conf import settings +from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured from django.core import validators - from django.db import backend, connection - -from django.utils.functional import curry -from django.utils.text import capfirst - from django.db.models.loading import get_installed_models, get_installed_model_modules from django.db.models.query import Q from django.db.models.manager import Manager from django.db.models.base import Model, AdminOptions - from django.db.models.fields import * from django.db.models.fields.related import * - -from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured from django.db.models.exceptions import FieldDoesNotExist, BadKeywordArguments from django.db.models import signals +from django.utils.functional import curry +from django.utils.text import capfirst # Admin stages. ADD, CHANGE, BOTH = 1, 2, 3 -#def get_module(app_label, module_name): -# return __import__('%s.%s.%s' % (MODEL_PREFIX, app_label, module_name), '', '', ['']) - def get_models(app): models = [] get_models_helper(app, models) diff --git a/django/db/models/exceptions.py b/django/db/models/exceptions.py index 28f085290a..b11ebaee0f 100644 --- a/django/db/models/exceptions.py +++ b/django/db/models/exceptions.py @@ -5,4 +5,4 @@ class BadKeywordArguments(Exception): pass class BadCommand(Exception): - pass \ No newline at end of file + pass diff --git a/django/db/models/loading.py b/django/db/models/loading.py index 115f223566..50ca6f47f6 100644 --- a/django/db/models/loading.py +++ b/django/db/models/loading.py @@ -23,7 +23,7 @@ def add_model_module(mod, modules): if hasattr(mod, '_MODELS'): modules.append(mod) for name in getattr(mod, '__all__', []): - submod = __import__("%s.%s" % ( mod.__name__, name),'','',['']) + submod = __import__("%s.%s" % (mod.__name__, name), '', '', ['']) add_model_module(submod, modules) def get_installed_model_modules(core_models=None): diff --git a/django/db/models/manager.py b/django/db/models/manager.py index 72bdc4a085..000aa4fdbb 100644 --- a/django/db/models/manager.py +++ b/django/db/models/manager.py @@ -191,7 +191,7 @@ class Manager(object): def get_in_bulk(self, id_list, *args, **kwargs): assert isinstance(id_list, list), "get_in_bulk() must be provided with a list of IDs." - assert id_list != [], "get_in_bulk() cannot be passed an empty ID list." + assert id_list != [], "get_in_bulk() cannot be passed an empty ID list." kwargs['where'] = ["%s.%s IN (%s)" % (backend.quote_name(self.klass._meta.db_table), backend.quote_name(self.klass._meta.pk.column), ",".join(['%s'] * len(id_list)))] kwargs['params'] = id_list obj_list = self.get_list(*args, **kwargs) @@ -257,4 +257,4 @@ class ManagerDescriptor(object): def __get__(self, instance, type=None): if instance != None: raise AttributeError, "Manager isn't accessible via %s instances" % type.__name__ - return self.manager \ No newline at end of file + return self.manager diff --git a/django/db/models/options.py b/django/db/models/options.py index 986c949ff8..f08ee5f501 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -15,7 +15,7 @@ get_verbose_name = lambda class_name: re.sub('([A-Z])', ' \\1', class_name).lowe DEFAULT_NAMES = ('module_name', 'verbose_name', 'verbose_name_plural', 'db_table', 'ordering', 'unique_together', 'admin','where_constraints', 'exceptions', 'permissions', - 'get_latest_by','order_with_respect_to', 'module_constants') + 'get_latest_by', 'order_with_respect_to', 'module_constants') class Options: def __init__(self, meta): @@ -33,7 +33,6 @@ class Options: self.order_with_respect_to = None self.module_constants = {} self.admin = None - self.meta = meta self.pk = None self.has_auto_field = False @@ -92,9 +91,6 @@ class Options: def __repr__(self): return '' % self.module_name - # def get_model_module(self): - # return get_module(self.app_label, self.module_name) - def get_content_type_id(self): "Returns the content-type ID for this object type." if not hasattr(self, '_content_type_id'): diff --git a/django/db/models/query.py b/django/db/models/query.py index 01fe4eda00..d96a3426d0 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -281,7 +281,7 @@ def lookup_inner(path, clause, value, opts, table, column): join_column = new_opts.object_name.lower() + '_id' intermediate_table = field.get_m2m_db_table(current_opts) - raise FieldFound() + raise FieldFound # Does the name belong to a reverse defined many-to-many field? field = find_field(name, current_opts.get_all_related_many_to_many_objects()) @@ -297,7 +297,7 @@ def lookup_inner(path, clause, value, opts, table, column): join_column = new_opts.object_name.lower() + '_id' intermediate_table = field.field.get_m2m_db_table(new_opts) - raise FieldFound() + raise FieldFound # Does the name belong to a one-to-many field? field = find_field(name, opts.get_all_related_objects()) @@ -310,7 +310,7 @@ def lookup_inner(path, clause, value, opts, table, column): # 1-N fields MUST be joined, regardless of any other conditions. join_required = True - raise FieldFound() + raise FieldFound # Does the name belong to a one-to-one, many-to-one, or regular field? field = find_field(name, current_opts.fields) @@ -321,7 +321,7 @@ def lookup_inner(path, clause, value, opts, table, column): new_column = new_opts.pk.column join_column = field.column - raise FieldFound() + raise FieldFound except FieldFound: # Match found, loop has been shortcut. pass diff --git a/django/db/models/related.py b/django/db/models/related.py index 7344d49173..fb10b7b8f8 100644 --- a/django/db/models/related.py +++ b/django/db/models/related.py @@ -1,12 +1,11 @@ from django.db.models.manipulators import ManipulatorCollection class RelatedManipulatorCollection(ManipulatorCollection): - def __init__(self,related, parent_name_parts , instance, follow): - name_parts = parent_name_parts + (related.var_name, ) + def __init__(self, related, parent_name_parts, instance, follow): + name_parts = parent_name_parts + (related.var_name,) self.instance = instance self.related = related - super(RelatedManipulatorCollection, self).__init__( - related.model,follow,name_parts) + super(RelatedManipulatorCollection, self).__init__(related.model, follow, name_parts) def _save_child(self, manip, parent_key): setattr(manip.original_object, self.related.field.attname, parent_key)