mirror of
https://github.com/django/django.git
synced 2024-12-23 09:36:06 +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:
parent
5d7af7b1a9
commit
54e5b9aa21
@ -399,10 +399,10 @@ def method_set_order(ordered_obj, self, id_list):
|
|||||||
cursor = connection.cursor()
|
cursor = connection.cursor()
|
||||||
# Example: "UPDATE poll_choices SET _order = %s WHERE poll_id = %s AND id = %s"
|
# 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" % \
|
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._meta.db_table), backend.quote_name('_order'),
|
||||||
backend.quote_name(ordered_obj.order_with_respect_to.column),
|
backend.quote_name(ordered_obj._meta.order_with_respect_to.column),
|
||||||
backend.quote_name(ordered_obj.pk.column))
|
backend.quote_name(ordered_obj._meta.pk.column))
|
||||||
rel_val = getattr(self, ordered_obj.order_with_respect_to.rel.field_name)
|
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)])
|
cursor.executemany(sql, [(i, rel_val, j) for i, j in enumerate(id_list)])
|
||||||
transaction.commit_unless_managed()
|
transaction.commit_unless_managed()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user