From 66c73a6bdc3c7c4e03ad59cb12c1d5156594f90c Mon Sep 17 00:00:00 2001 From: Brandon Taylor Date: Wed, 27 Jan 2016 10:58:58 -0500 Subject: [PATCH] Fixed access of custom order property in model meta, falling back to order for legacy implementations. Updated readme and version bump to 2.0.10 --- README.md | 9 ++++----- README.rst | 16 +++++++++------- adminsortable/__init__.py | 4 ++++ adminsortable/admin.py | 8 +++++++- sample_project/database/test_project.sqlite | Bin 89088 -> 89088 bytes 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9b60738..2124681 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![Build Status](https://travis-ci.org/iambrandontaylor/django-admin-sortable.svg?branch=master)](https://travis-ci.org/iambrandontaylor/django-admin-sortable) -Current version: 2.0.9 +Current version: 2.0.10 This project makes it easy to add drag-and-drop ordering to any model in Django admin. Inlines for a sortable model may also be made sortable, @@ -27,7 +27,7 @@ django-admin-sortable 1.7.1 and higher are compatible with Python 3. Download django-admin-sortable from [source](https://github.com/iambrandontaylor/django-admin-sortable/archive/master.zip) 1. Unzip the directory and cd into the uncompressed project directory -2. *Optional: Enable your virtualenv +2. * Optional: Enable your virtualenv 3. Run `$ python setup.py install` or add `adminsortable` to your PYTHONPATH. @@ -457,9 +457,8 @@ ordering on top of that just seemed a little much in my opinion. django-admin-sortable is currently used in production. -### What's new in 2.0.9? -- Added icons for sortable elements -- Refactored determination of sortability of fields that are instances of `SortableForeignKey` in admin +### What's new in 2.0.10? +- Bugfix for accessing custom `order` property of model. Thanks [@theithec](https://github.com/theithec) for reporting the issue. ### Future diff --git a/README.rst b/README.rst index 12b475c..95c7ea4 100644 --- a/README.rst +++ b/README.rst @@ -3,7 +3,7 @@ Django Admin Sortable |Build Status| -Current version: 2.0.9 +Current version: 2.0.10 This project makes it easy to add drag-and-drop ordering to any model in Django admin. Inlines for a sortable model may also be made sortable, @@ -36,7 +36,10 @@ Download django-admin-sortable from `source `__ 1. Unzip the directory and cd into the uncompressed project directory -2. \*Optional: Enable your virtualenv +2. + + - Optional: Enable your virtualenv + 3. Run ``$ python setup.py install`` or add ``adminsortable`` to your PYTHONPATH. @@ -593,12 +596,11 @@ Status django-admin-sortable is currently used in production. -What's new in 2.0.9? -~~~~~~~~~~~~~~~~~~~~ +What's new in 2.0.10? +~~~~~~~~~~~~~~~~~~~~~ -- Added icons for sortable elements -- Refactored determination of sortability of fields that are instances - of ``SortableForeignKey`` in admin +- Bugfix for accessing custom ``order`` property of model. Thanks + [@theithec](https://github.com/theithec) for reporting the issue. Future ~~~~~~ diff --git a/adminsortable/__init__.py b/adminsortable/__init__.py index 1facb45..624e90a 100644 --- a/adminsortable/__init__.py +++ b/adminsortable/__init__.py @@ -1,4 +1,8 @@ +<<<<<<< Updated upstream VERSION = (2, 0, 8) # following PEP 386 +======= +VERSION = (2, 0, 10) # following PEP 386 +>>>>>>> Stashed changes DEV_N = None diff --git a/adminsortable/admin.py b/adminsortable/admin.py index 2def272..6cf05e7 100755 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -188,7 +188,13 @@ class SortableAdmin(SortableAdminBase, ModelAdmin): # Order the objects by the property they are sortable by, # then by the order, otherwise the regroup # template tag will not show the objects correctly - objects = objects.order_by(sortable_by_expression, 'order') + + try: + order_field_name = opts.model._meta.ordering[0] + except IndexError: + order_field_name = 'order' + + objects = objects.order_by(sortable_by_expression, order_field_name) try: verbose_name_plural = opts.verbose_name_plural.__unicode__() diff --git a/sample_project/database/test_project.sqlite b/sample_project/database/test_project.sqlite index 84ca6166ee6bb08e5bfaef66ab4b08462df6ed64..b09cb9cd68c90c9398061e43e1f1c18f1669c402 100644 GIT binary patch delta 1231 zcmah|U1(cn82;Yx{Z7)HCTY^2WUgy-QtR4_C7hq8CrvN5Scp!Vt+0Zq)0#CgHrS?3 z&ibP$V+Oq$=saND&2aXz7t3~FDM}c0>|*X>C~PvY%(>n8Gjs}5P{i*<+=>%+;C!6- zd!O?@&-c9Fdt_ZWvM#*e?P(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