diff --git a/README.md b/README.md index 91abd5d..e017bb0 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, @@ -35,7 +35,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. @@ -460,9 +460,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 450e800..9aa2fd1 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, @@ -50,7 +50,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. @@ -604,12 +607,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 56d377e..25cbabc 100644 --- a/adminsortable/__init__.py +++ b/adminsortable/__init__.py @@ -1,4 +1,4 @@ -VERSION = (2, 0, 9) # following PEP 386 +VERSION = (2, 0, 10) DEV_N = None diff --git a/adminsortable/admin.py b/adminsortable/admin.py index 2def272..0a6b21c 100755 --- a/adminsortable/admin.py +++ b/adminsortable/admin.py @@ -29,7 +29,7 @@ from django.template.defaultfilters import capfirst from adminsortable.fields import SortableForeignKey from adminsortable.models import SortableMixin -from adminsortable.utils import get_is_sortable, check_model_is_sortable +from adminsortable.utils import get_is_sortable STATIC_URL = settings.STATIC_URL @@ -188,7 +188,16 @@ 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 (AttributeError, IndexError): + # for Django 1.5.x + order_field_name = opts.ordering[0] + finally: + 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