Ticket #2196: method_set_order.diff

File method_set_order.diff, 1.1 KB (added by fonso, 18 years ago)

Patch for method_set_order

  • django/db/models/base.py

     
    389389    cursor = connection.cursor()
    390390    # Example: "UPDATE poll_choices SET _order = %s WHERE poll_id = %s AND id = %s"
    391391    sql = "UPDATE %s SET %s = %%s WHERE %s = %%s AND %s = %%s" % \
    392         (backend.quote_name(ordered_obj.db_table), backend.quote_name('_order'),
    393         backend.quote_name(ordered_obj.order_with_respect_to.column),
    394         backend.quote_name(ordered_obj.pk.column))
    395     rel_val = getattr(self, ordered_obj.order_with_respect_to.rel.field_name)
     392        (backend.quote_name(ordered_obj._meta.db_table), backend.quote_name('_order'),
     393        backend.quote_name(ordered_obj._meta.order_with_respect_to.column),
     394        backend.quote_name(ordered_obj._meta.pk.column))
     395    rel_val = getattr(self, ordered_obj._meta.order_with_respect_to.rel.field_name)
    396396    cursor.executemany(sql, [(i, rel_val, j) for i, j in enumerate(id_list)])
    397397    transaction.commit_unless_managed()
    398398
Back to Top