Opened 14 years ago

Last modified 5 years ago

#2137 new New feature

Add drag and drop ordering for inlines to set order_with_respect_to in admin interface

Reported by: anonymous Owned by: xian
Component: contrib.admin Version:
Severity: Normal Keywords:
Cc: russell@…, gary.wilson@…, mathijs@…, sun.void@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Pre-MR, adding order_with_respect_to would present an ordering field in the admin interface (or a draggable list of inline objects if dom-drag.js was installed). Post M-R, neither appears. Not sure if this is a problem at the template level or at the model level.

Attachments (1)

get_ordered_objects_r15376.patch (1.6 KB) - added by Mathijs de Bruin 10 years ago.
Updated patch for Django SVN r15376

Download all attachments as: .zip

Change History (15)

comment:1 Changed 14 years ago by russell@…

Cc: russell@… added
Summary: order_with_respect_to in M-R has no affect on admin interface[patch] order_with_respect_to in M-R has no affect on admin interface

Hi,

The following patch works for me:

--- django/db/models/options.py (revision 3908)
+++ django/db/models/options.py (working copy)
@@ -2,7 +2,7 @@
 from django.db.models.related import RelatedObject
 from django.db.models.fields.related import ManyToManyRel
 from django.db.models.fields import AutoField, FieldDoesNotExist
-from django.db.models.loading import get_models
+from django.db.models.loading import get_models, get_apps, get_model
 from django.db.models.query import orderlist2sql
 from django.db.models import Manager
 from bisect import bisect
@@ -164,12 +164,12 @@
         "Returns a list of Options objects that are ordered with respect to this object."
         if not hasattr(self, '_ordered_objects'):
             objects = []
-            # TODO
-            #for klass in get_models(get_app(self.app_label)):
-            #    opts = klass._meta
-            #    if opts.order_with_respect_to and opts.order_with_respect_to.rel \
-            #        and self == opts.order_with_respect_to.rel.to._meta:
-            #        objects.append(opts)
+            for app in get_apps():
+                for model in get_models(app):
+                    opts = model._meta
+                    if opts.order_with_respect_to and opts.order_with_respect_to.rel \
+                        and self == opts.order_with_respect_to.rel.to._meta:
+                        objects.append(opts)
             self._ordered_objects = objects
         return self._ordered_objects

Just ... don't install dom-drag.js or the field will be greyed out :)

I'm working on re-implementing the drag-n-drop functionality[1] and will update this bug or file another when I've done that.

[1] http://groups.google.com/group/django-developers/browse_thread/thread/2af467c292b87067/0b64ccf351cf7542

Russell

comment:2 Changed 14 years ago by Gary Wilson <gary.wilson@…>

Cc: gary.wilson@… added

comment:3 Changed 14 years ago by Russell Cloran <russell@…>

I have a "working" patch for this. It uses dojo for the JavaScript, and only works for one related model. Oh, and only for edit_inline_tabular. ie, it's not ready for contribution by any means.

If you're interested in getting it anyways (there was some interest on the mailing list), please mail me directly.

comment:4 Changed 14 years ago by Chris Beaven

Triage Stage: UnreviewedAccepted

comment:5 Changed 13 years ago by James Bennett

Owner: changed from nobody to xian

Reassigning to xian since I know he's working on the JS stuff for newforms-admin.

comment:6 Changed 13 years ago by James Wheare

Resolution: duplicate
Status: newclosed

Dupe of #13

comment:7 Changed 10 years ago by Mathijs de Bruin

Cc: mathijs@… added
Resolution: duplicate
Status: closedreopened

This is not merely a dup. of #13, allthough it might be part of that one. Moreover, it has surely not been fixed.

Last edited 10 years ago by Mathijs de Bruin (previous) (diff)

Changed 10 years ago by Mathijs de Bruin

Updated patch for Django SVN r15376

comment:8 Changed 9 years ago by Łukasz Rekucki

Type: defectBug

comment:9 Changed 9 years ago by Łukasz Rekucki

Severity: normalNormal

comment:10 Changed 9 years ago by Jannis Leidel

Easy pickings: unset
Needs tests: set

comment:11 Changed 9 years ago by Simon Meers

Patch needs improvement: set
UI/UX: unset

Is there an advantage in using nested get_app/get_models(app) rather than just using get_models()?

Also the _order field is marked as editable=False, so this in itself is insufficient for making it appear.

comment:12 Changed 8 years ago by Alexey Boriskin

Cc: sun.void@… added

comment:13 Changed 7 years ago by Aymeric Augustin

Status: reopenednew

comment:14 Changed 5 years ago by Tim Graham

Has patch: unset
Needs tests: unset
Patch needs improvement: unset
Summary: [patch] order_with_respect_to in M-R has no affect on admin interfaceAdd drag and drop ordering for inlines to set order_with_respect_to in admin interface
Type: BugNew feature
Note: See TracTickets for help on using tickets.
Back to Top