From ea2291699ce70f0d75a58855f13ed424f105db2a Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Thu, 22 Aug 2013 12:17:38 -0400 Subject: [PATCH] Merged pull request 55463877336eced1881e23c543a46242f2a62a9c. Updated README with instructions for adding the necessary JS and CSS files to enable sortable inline modesl whose parent does not inherit from Sortable. --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 06ae919..14fc907 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Use the [staticfiles app](https://docs.djangoproject.com/en/1.4/ref/contrib/stat Alternate: Copy the `adminsortable` folder from the `static` folder to the -location you server static files from. +location you serve static files from. ### Testing Have a look at the included sample_project to see working examples. @@ -105,7 +105,7 @@ See: [this link](http://south.readthedocs.org/en/latest/tutorial/part3.html) for information on Data Migrations. -### Django Admin +### Django Admin Integration To enable sorting in the admin, you need to inherit from `SortableAdmin`: from django.contrib import admin @@ -207,6 +207,30 @@ stacked inline is going to be very tall, I would suggest using TabularStackedInline instead. +### Known Issue(s) +Because of the way inline models are added to their parent model in the +change form, it is not currently possible to have sortable inline models +whose parent does not inhert from `Sortable`, without adding the necessary +JavaScript and CSS files to the change form manually. + +Example: + + class GalleryImageInline(SortableTabularInline): + model = GalleryImage # inherits from Sortable + + class GalleryAlbumAdmin # GalleryAlbum does not inherit Sortable + class Media: + js = ( + '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', + '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js', + # 'adminsortable/js/admin.sortable.stacked.inlines.js', + 'adminsortable/js/admin.sortable.tabular.inlines.js', + ) + css = { + 'screen': ('adminsortable/css/admin.sortable.inline.css'), + } + + ### Rationale Other projects have added drag-and-drop ordering to the ChangeList view, however this introduces a couple of problems...