1
0
mirror of https://github.com/django/django.git synced 2024-12-23 01:25:58 +00:00

Fixed #2196 -- Fixed AttributeError in method_set_order. Thanks, fonso

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3220 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2006-06-28 01:16:32 +00:00
parent 5d7af7b1a9
commit 54e5b9aa21

View File

@ -399,10 +399,10 @@ def method_set_order(ordered_obj, self, id_list):
cursor = connection.cursor()
# Example: "UPDATE poll_choices SET _order = %s WHERE poll_id = %s AND id = %s"
sql = "UPDATE %s SET %s = %%s WHERE %s = %%s AND %s = %%s" % \
(backend.quote_name(ordered_obj.db_table), backend.quote_name('_order'),
backend.quote_name(ordered_obj.order_with_respect_to.column),
backend.quote_name(ordered_obj.pk.column))
rel_val = getattr(self, ordered_obj.order_with_respect_to.rel.field_name)
(backend.quote_name(ordered_obj._meta.db_table), backend.quote_name('_order'),
backend.quote_name(ordered_obj._meta.order_with_respect_to.column),
backend.quote_name(ordered_obj._meta.pk.column))
rel_val = getattr(self, ordered_obj._meta.order_with_respect_to.rel.field_name)
cursor.executemany(sql, [(i, rel_val, j) for i, j in enumerate(id_list)])
transaction.commit_unless_managed()