Ticket #6088: _get_next_or_previous_in_order.diff
File _get_next_or_previous_in_order.diff, 743 bytes (added by , 17 years ago) |
---|
-
db/models/base.py
361 361 qn(self._meta.db_table), qn(self._meta.pk.column)), 362 362 '%s=%%s' % qn(order_field.column)] 363 363 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() 365 366 setattr(self, cachename, obj) 366 367 return getattr(self, cachename) 367 368