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 84ca616..b09cb9c 100644 Binary files a/sample_project/database/test_project.sqlite and b/sample_project/database/test_project.sqlite differ