Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

magic-removal: Fixed #1598 -- Removed some references to get_object()

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2644 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 74be99501473433d6e43024d2d8d3fc0bbeb9fc3 1 parent 8d9ebc6
@adrianholovaty adrianholovaty authored
View
13 django/db/models/base.py
@@ -277,13 +277,12 @@ def _get_next_or_previous_in_order(self, is_next):
if not hasattr(self, cachename):
op = is_next and '>' or '<'
order_field = self.order_with_respect_to
- obj = self._default_manager.get_object(order_by=('_order',),
- where=['%s %s (SELECT %s FROM %s WHERE %s=%%s)' % \
- (backend.quote_name('_order'), op, backend.quote_name('_order'),
- backend.quote_name(opts.db_table), backend.quote_name(opts.pk.column)),
- '%s=%%s' % backend.quote_name(order_field.column)],
- limit=1,
- params=[self._get_pk_val(), getattr(self, order_field.attname)])
+ where = ['%s %s (SELECT %s FROM %s WHERE %s=%%s)' % \
+ (backend.quote_name('_order'), op, backend.quote_name('_order'),
+ backend.quote_name(opts.db_table), backend.quote_name(opts.pk.column)),
+ '%s=%%s' % backend.quote_name(order_field.column)]
+ params = [self._get_pk_val(), getattr(self, order_field.attname)]
+ obj = self._default_manager.order_by('_order').extra(where=where, params=params)[:1].get()
setattr(self, cachename, obj)
return getattr(self, cachename)
View
4 django/db/models/fields/related.py
@@ -38,7 +38,7 @@ def manipulator_valid_rel_key(f, self, field_data, all_data):
"Validates that the value is a valid foreign key"
klass = f.rel.to
try:
- klass._default_manager.get_object(pk=field_data)
+ klass._default_manager.get(pk=field_data)
except klass.DoesNotExist:
raise validators.ValidationError, _("Please enter a valid %s.") % f.verbose_name
@@ -392,7 +392,7 @@ def __get__(self, instance, instance_type=None):
rel_model=self.field.rel.to
superclass = rel_model._default_manager.__class__
RelatedManager = create_many_related_manager(superclass)
-
+
qn = backend.quote_name
manager = RelatedManager(
model=rel_model,
View
2  django/db/models/manipulators.py
@@ -263,7 +263,7 @@ def __init__(self, obj_key, follow=None):
# Let the ObjectDoesNotExist exception propogate up.
lookup_kwargs = self.opts.one_to_one_field.rel.limit_choices_to
lookup_kwargs['%s__exact' % self.opts.one_to_one_field.rel.field_name] = obj_key
- _ = self.opts.one_to_one_field.rel.to.get_model_module().get_object(**lookup_kwargs)
+ self.opts.one_to_one_field.rel.to.get_model_module().get(**lookup_kwargs)
params = dict([(f.attname, f.get_default()) for f in self.opts.fields])
params[self.opts.pk.attname] = obj_key
self.original_object = self.opts.get_model_module().Klass(**params)
Please sign in to comment.
Something went wrong with that request. Please try again.