Opened 9 years ago

Last modified 3 weeks 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 dokterbob 5 years ago.
Updated patch for Django SVN r15376

Download all attachments as: .zip

Change History (15)

comment:1 Changed 9 years ago by russell@…

  • Cc russell@… added
  • Summary changed from order_with_respect_to in M-R has no affect on admin interface to [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 9 years ago by Gary Wilson <gary.wilson@…>

  • Cc gary.wilson@… added

comment:3 Changed 9 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 9 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Accepted

comment:5 Changed 8 years ago by ubernostrum

  • 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 8 years ago by James Wheare

  • Resolution set to duplicate
  • Status changed from new to closed

Dupe of #13

comment:7 Changed 5 years ago by dokterbob

  • Cc mathijs@… added
  • Resolution duplicate deleted
  • Status changed from closed to reopened

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

Version 0, edited 5 years ago by dokterbob (next)

Changed 5 years ago by dokterbob

Updated patch for Django SVN r15376

comment:8 Changed 4 years ago by lrekucki

  • Type changed from defect to Bug

comment:9 Changed 4 years ago by lrekucki

  • Severity changed from normal to Normal

comment:10 Changed 4 years ago by jezdez

  • Easy pickings unset
  • Needs tests set

comment:11 Changed 4 years ago by DrMeers

  • 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 3 years ago by void

  • Cc sun.void@… added

comment:13 Changed 2 years ago by aaugustin

  • Status changed from reopened to new

comment:14 Changed 3 weeks ago by timgraham

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