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
|
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.
Change History
(17)
| 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
|
| Triage Stage: |
Unreviewed → Accepted
|
| Owner: |
changed from nobody to xian
|
| Resolution: |
→ duplicate
|
| Status: |
new → closed
|
| Cc: |
mathijs@… added
|
| Resolution: |
duplicate
|
| Status: |
closed → reopened
|
| Severity: |
normal → Normal
|
| Easy pickings: |
unset
|
| Needs tests: |
set
|
| Patch needs improvement: |
set
|
| UI/UX: |
unset
|
| Has patch: |
unset
|
| Needs tests: |
unset
|
| Patch needs improvement: |
unset
|
| Summary: |
[patch] order_with_respect_to in M-R has no affect on admin interface → Add drag and drop ordering for inlines to set order_with_respect_to in admin interface
|
| Type: |
Bug → New feature
|
| Owner: |
xian removed
|
| Status: |
new → assigned
|
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_objectsJust ... 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