Opened 18 years ago

Last modified 2 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:
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 13 years ago.
Updated patch for Django SVN r15376

Download all attachments as: .zip

Change History (17)

comment:1 by russell@…, 17 years ago

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 by Gary Wilson <gary.wilson@…>, 17 years ago

Cc: gary.wilson@… added

comment:3 by Russell Cloran <russell@…>, 17 years ago

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 by Chris Beaven, 17 years ago

Triage Stage: UnreviewedAccepted

comment:5 by James Bennett, 17 years ago

Owner: changed from nobody to xian

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

comment:6 by James Wheare, 16 years ago

Resolution: duplicate
Status: newclosed

Dupe of #13

comment:7 by Mathijs de Bruin, 13 years ago

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 13 years ago by Mathijs de Bruin (previous) (diff)

by Mathijs de Bruin, 13 years ago

Updated patch for Django SVN r15376

comment:8 by Łukasz Rekucki, 13 years ago

Type: defectBug

comment:9 by Łukasz Rekucki, 13 years ago

Severity: normalNormal

comment:10 by Jannis Leidel, 13 years ago

Easy pickings: unset
Needs tests: set

comment:11 by Simon Meers, 13 years ago

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 by Alexey Boriskin, 12 years ago

Cc: sun.void@… added

comment:13 by Aymeric Augustin, 11 years ago

Status: reopenednew

comment:14 by Tim Graham, 9 years ago

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

comment:15 by Mariusz Felisiak, 2 years ago

Owner: xian removed
Status: newassigned

comment:16 by Mariusz Felisiak, 2 years ago

Status: assignednew
Note: See TracTickets for help on using tickets.
Back to Top