Ticket #6088: _get_next_or_previous_in_order.diff

File _get_next_or_previous_in_order.diff, 743 bytes (added by James Wheare <django@…>, 7 years ago)
  • db/models/base.py

     
    361361                qn(self._meta.db_table), qn(self._meta.pk.column)),
    362362                '%s=%%s' % qn(order_field.column)]
    363363            params = [self._get_pk_val(), getattr(self, order_field.attname)]
    364             obj = self._default_manager.order_by('_order').extra(where=where, params=params)[:1].get()
     364            direction = is_next and '' or '-'
     365            obj = self._default_manager.order_by('%s_order' % direction).extra(where=where, params=params)[:1].get()
    365366            setattr(self, cachename, obj)
    366367        return getattr(self, cachename)
    367368
Back to Top