Django

Code

Ticket #2895 (closed: fixed)

Opened 2 years ago

Last modified 3 weeks ago

Sorting on ForeignKey field whose model uses desc ordering breaks admin change_list

Reported by: django@55minutes.com Assigned to: nobody
Milestone: Component: Admin interface
Version: Keywords: nfa-fixed
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

On line 709 of contrib.admin.views.main.ChangeList , the lookup assumes that f.rel.to._meta.ordering[0] will return a valid column name. Not so in the case of '-fieldname'.

Attachments

django.contrib.admin.views.main.py.diff (415 bytes) - added by Ben Ford <ben.fordnz@gmail.com> on 11/17/06 17:23:25.
diff of the necessary changes to django.contrib.admin.views.main.py
main.diff (0.8 kB) - added by Sergey Kirillov <rushman@mail.ru> on 01/11/07 07:48:50.
Updated patch

Change History

11/17/06 17:22:44 changed by ben.fordnz@gmail.com

Here's a quick hack that solves this problem for me. It's not tested, but it seems to work in my case. 709,713c709 < o_field = f.rel.to._meta.ordering[0] < if o_field[0] == '-': < self.order_type = 'desc' < o_field = o_field[1:] < rel_ordering = f.rel.to._meta.ordering and o_field or f.rel.to._meta.pk.column ---

rel_ordering = f.rel.to._meta.ordering and f.rel.to._meta.ordering[0] or f.rel.to._meta.pk.column

11/17/06 17:23:25 changed by Ben Ford <ben.fordnz@gmail.com>

  • attachment django.contrib.admin.views.main.py.diff added.

diff of the necessary changes to django.contrib.admin.views.main.py

11/17/06 17:25:05 changed by Ben Ford <ben.fordnz@gmail.com>

  • summary changed from Sorting on FK model with desc ordering breaks admin change_list to [patch] Sorting on FK model with desc ordering breaks admin change_list.

01/11/07 07:48:27 changed by Sergey Kirillov <rushman@mail.ru>

Patch from this ticket breaks ability to change sorting of rows by clicking on column header. With this patch clicking on column header has no effect.

01/11/07 07:48:50 changed by Sergey Kirillov <rushman@mail.ru>

  • attachment main.diff added.

Updated patch

02/02/07 22:29:25 changed by Gary Wilson <gary.wilson@gmail.com>

  • stage changed from Unreviewed to Accepted.

It has been mentioned that this ticket might be fixed by #3002.

08/07/07 17:00:25 changed by gwilson

  • summary changed from [patch] Sorting on FK model with desc ordering breaks admin change_list to Sorting on ForeignKey field whose model uses desc ordering breaks admin change_list.

08/07/07 17:01:49 changed by gwilson

Note, this was fixed in newforms-admin branch in [5122].

12/05/07 14:26:28 changed by ubernostrum

#6127 was a duplicate.

02/08/08 13:12:21 changed by ramiro

  • keywords set to nfa-fixed.

08/01/08 10:57:43 changed by brosner

  • status changed from new to closed.
  • resolution set to fixed.

This is no longer a problem since the merge of newforms-admin in [7967].


Add/Change #2895 (Sorting on ForeignKey field whose model uses desc ordering breaks admin change_list)




Change Properties
Action