Version bump to 2.1.3

Updated readme with credits for translations.
master
Brandon Taylor 2018-02-25 11:49:38 -05:00
parent f2df915a13
commit f515f93d22
3 changed files with 70 additions and 68 deletions

View File

@ -531,8 +531,8 @@ ordering on top of that just seemed a little much in my opinion.
### Status ### Status
django-admin-sortable is currently used in production. django-admin-sortable is currently used in production.
### What's new in 2.1.2? ### What's new in 2.1.3?
- Django 2 compatibility - Norwegian and Latvian translations. Credit to [simenheg](https://github.com/simenheg) and [peterisb](https://github.com/peterisb) respectively.
### Future ### Future
- Better template support for foreign keys that are self referential. If someone would like to take on rendering recursive sortables, that would be super. - Better template support for foreign keys that are self referential. If someone would like to take on rendering recursive sortables, that would be super.

View File

@ -36,7 +36,7 @@ Django 1.4.x
django-admin-sortable 1.6.6 introduced a backward-incompatible change django-admin-sortable 1.6.6 introduced a backward-incompatible change
for the ``sorting_filters`` attribute. Please convert your attributes to for the ``sorting_filters`` attribute. Please convert your attributes to
the new tuple-based format if you haven't already. the new tuple-based format if you havent already.
django-admin-sortable 1.7.1 and higher are compatible with Python 3. django-admin-sortable 1.7.1 and higher are compatible with Python 3.
@ -45,7 +45,7 @@ Installation
1. ``$ pip install django-admin-sortable`` 1. ``$ pip install django-admin-sortable``
--or-- or
Download django-admin-sortable from Download django-admin-sortable from
`source <https://github.com/iambrandontaylor/django-admin-sortable/archive/master.zip>`__ `source <https://github.com/iambrandontaylor/django-admin-sortable/archive/master.zip>`__
@ -84,11 +84,11 @@ to the location you serve static files from.
Testing Testing
~~~~~~~ ~~~~~~~
Have a look at the included sample\_project to see working examples. The Have a look at the included sample_project to see working examples. The
login credentials for admin are: admin/admin login credentials for admin are: admin/admin
When a model is sortable, a tool-area link will be added that says When a model is sortable, a tool-area link will be added that says
"Change Order". Click this link, and you will be taken to the custom “Change Order”. Click this link, and you will be taken to the custom
view where you can drag-and-drop the records into order. view where you can drag-and-drop the records into order.
Inlines may be drag-and-dropped into any order directly from the change Inlines may be drag-and-dropped into any order directly from the change
@ -100,11 +100,11 @@ Usage
Models Models
~~~~~~ ~~~~~~
To add "sortability" to a model, you need to inherit ``SortableMixin`` To add “sortability” to a model, you need to inherit ``SortableMixin``
and at minimum, define: and at minimum, define:
- The field which should be used for ``Meta.ordering``, which must - The field which should be used for ``Meta.ordering``, which must
resolve to one of the integer fields defined in Django's ORM: resolve to one of the integer fields defined in Djangos ORM:
- ``PositiveIntegerField`` - ``PositiveIntegerField``
- ``IntegerField`` - ``IntegerField``
- ``PositiveSmallIntegerField`` - ``PositiveSmallIntegerField``
@ -114,7 +114,7 @@ and at minimum, define:
- ``Meta.ordering`` **must only contain one value**, otherwise, your - ``Meta.ordering`` **must only contain one value**, otherwise, your
objects will not be sorted correctly. objects will not be sorted correctly.
- **IMPORTANT**: You must name the field you use for ordering something - **IMPORTANT**: You must name the field you use for ordering something
other than "order\_field" as this name is reserved by the other than “order_field” as this name is reserved by the
``SortableMixin`` class. ``SortableMixin`` class.
- It is recommended that you set ``editable=False`` and - It is recommended that you set ``editable=False`` and
``db_index=True`` on the field defined in ``Meta.ordering`` for a ``db_index=True`` on the field defined in ``Meta.ordering`` for a
@ -143,14 +143,14 @@ Sample Model:
def __unicode__(self): def __unicode__(self):
return self.title return self.title
Support for models that don't use an ``AutoField`` for their primary key Support for models that dont use an ``AutoField`` for their primary key
are also supported in version 2.0.20 or higher. are also supported in version 2.0.20 or higher.
Common Use Case Common Use Case
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
A common use case is to have child objects that are sortable relative to A common use case is to have child objects that are sortable relative to
a parent. If your parent object is also sortable, here's how you would a parent. If your parent object is also sortable, heres how you would
set up your models and admin options: set up your models and admin options:
.. code:: python .. code:: python
@ -241,7 +241,7 @@ will be grouped by the non-sortable foreign key when sorting.
Backwards Compatibility Backwards Compatibility
~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
If you previously used Django Admin Sortable, **DON'T PANIC** - If you previously used Django Admin Sortable, **DONT PANIC** -
everything will still work exactly as before ***without any changes to everything will still work exactly as before ***without any changes to
your code***. Going forward, it is recommended that you use the new your code***. Going forward, it is recommended that you use the new
``SortableMixin`` on your models, as pre-2.0 compatibility might not be ``SortableMixin`` on your models, as pre-2.0 compatibility might not be
@ -252,17 +252,17 @@ hard-coded ``order`` field, and meta inheritance requirements:
.. code:: python .. code:: python
# legacy model definition # legacy model definition
from adminsortable.models import Sortable from adminsortable.models import Sortable
class Project(Sortable): class Project(Sortable):
class Meta(Sortable.Meta): class Meta(Sortable.Meta):
pass pass
title = models.CharField(max_length=50) title = models.CharField(max_length=50)
def __unicode__(self): def __unicode__(self):
return self.title return self.title
Model Instance Methods Model Instance Methods
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^
@ -289,7 +289,7 @@ following data:
| | Child Model 4 | | | Child Model 4 |
| | Child Model 5 | | | Child Model 5 |
"Child Model 2" ``get_next()`` would return ``None`` "Child Model 3" “Child Model 2” ``get_next()`` would return ``None`` “Child Model 3”
``get_previous`` would return ``None`` ``get_previous`` would return ``None``
If you wish to override this behavior, pass in: If you wish to override this behavior, pass in:
@ -299,7 +299,7 @@ If you wish to override this behavior, pass in:
your_instance.get_next(filter_on_sortable_fk=False) your_instance.get_next(filter_on_sortable_fk=False)
You may also pass in additional ORM "extra\_filters" as a dictionary, You may also pass in additional ORM “extra_filters” as a dictionary,
should you need to: should you need to:
.. code:: python .. code:: python
@ -312,13 +312,13 @@ Adding Sorting to an existing model
Django 1.5.x to 1.6.x Django 1.5.x to 1.6.x
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
If you're adding Sorting to an existing model, it is recommended that If youre adding Sorting to an existing model, it is recommended that
you use `django-south <http://south.areacode.com/>`__ to create a schema you use `django-south <http://south.areacode.com/>`__ to create a schema
migration to add the "order" field to your model. You will also need to migration to add the “order” field to your model. You will also need to
create a data migration in order to add the appropriate values for the create a data migration in order to add the appropriate values for the
"order" column. “order” column.
Example assuming a model named "Category": Example assuming a model named “Category”:
.. code:: python .. code:: python
@ -334,7 +334,7 @@ more information on South Data Migrations.
Django 1.7.x or higher Django 1.7.x or higher
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^
Since schema migrations are built into Django 1.7, you don't have to use Since schema migrations are built into Django 1.7, you dont have to use
south, but the process of adding and running migrations is nearly south, but the process of adding and running migrations is nearly
identical. Take a look at the identical. Take a look at the
`Migrations <https://docs.djangoproject.com/en/1.7/topics/migrations/>`__ `Migrations <https://docs.djangoproject.com/en/1.7/topics/migrations/>`__
@ -405,8 +405,8 @@ Overriding ``queryset()``
django-admin-sortable supports custom queryset overrides on admin models django-admin-sortable supports custom queryset overrides on admin models
and inline models in Django admin! and inline models in Django admin!
If you're providing an override of a SortableAdmin or Sortable inline If youre providing an override of a SortableAdmin or Sortable inline
model, you don't need to do anything extra. django-admin-sortable will model, you dont need to do anything extra. django-admin-sortable will
automatically honor your queryset. automatically honor your queryset.
Have a look at the WidgetAdmin class in the sample project for an Have a look at the WidgetAdmin class in the sample project for an
@ -441,7 +441,7 @@ properly determine the sortability of your model. Example:
return qs return qs
If you override the queryset of an inline, the number of objects present If you override the queryset of an inline, the number of objects present
may change, and adminsortable won't be able to automatically determine may change, and adminsortable wont be able to automatically determine
if the inline model is sortable from here, which is why we have to set if the inline model is sortable from here, which is why we have to set
the ``is_sortable`` property of the model in this method. the ``is_sortable`` property of the model in this method.
@ -453,28 +453,28 @@ a ``sorting_filters`` tuple. This works exactly the same as
``.filter()`` on a QuerySet, and is applied *after* ``get_queryset()`` ``.filter()`` on a QuerySet, and is applied *after* ``get_queryset()``
on the admin class, allowing you to override the queryset as you would on the admin class, allowing you to override the queryset as you would
normally in admin but apply additional filters for sorting. The text normally in admin but apply additional filters for sorting. The text
"Change Order of" will appear before each filter in the Change List “Change Order of” will appear before each filter in the Change List
template, and the filter groups are displayed from left to right in the template, and the filter groups are displayed from left to right in the
order listed. If no ``sorting_filters`` are specified, the text "Change order listed. If no ``sorting_filters`` are specified, the text Change
Order" will be displayed for the link. Order will be displayed for the link.
Self-Referential SortableForeignKey Self-Referential SortableForeignKey
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You can specify a self-referential SortableForeignKey field, however the You can specify a self-referential SortableForeignKey field, however the
admin interface will currently show a model that is a grandchild at the admin interface will currently show a model that is a grandchild at the
same level as a child. I'm working to resolve this issue. same level as a child. Im working to resolve this issue.
Important! Important!
'''''''''' ''''''''''
django-admin-sortable 1.6.6 introduced a backwards-incompatible change django-admin-sortable 1.6.6 introduced a backwards-incompatible change
for ``sorting_filters``. Previously this attribute was defined as a for ``sorting_filters``. Previously this attribute was defined as a
dictionary, so you'll need to change your values over to the new dictionary, so youll need to change your values over to the new
tuple-based format. tuple-based format.
An example of sorting subsets would be a "Board of Directors". In this An example of sorting subsets would be a “Board of Directors”. In this
use case, you have a list of "People" objects. Some of these people are use case, you have a list of “People” objects. Some of these people are
on the Board of Directors and some not, and you need to sort them on the Board of Directors and some not, and you need to sort them
independently. independently.
@ -499,9 +499,9 @@ independently.
Extending custom templates Extending custom templates
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^
By default, adminsortable's change form and change list views inherit By default, adminsortables change form and change list views inherit
from Django admin's standard templates. Sometimes you need to have a from Django admins standard templates. Sometimes you need to have a
custom change form or change list, but also need adminsortable's CSS and custom change form or change list, but also need adminsortables CSS and
JavaScript for inline models that are sortable for example. JavaScript for inline models that are sortable for example.
SortableAdmin has two attributes you can override for this use case: SortableAdmin has two attributes you can override for this use case:
@ -515,12 +515,12 @@ These attributes have default values of:
.. code:: python .. code:: python
change_form_template_extends = 'admin/change_form.html' change_form_template_extends = 'admin/change_form.html'
change_list_template_extends = 'admin/change_list.html' change_list_template_extends = 'admin/change_list.html'
If you need to extend the inline change form templates, you'll need to If you need to extend the inline change form templates, youll need to
select the right one, depending on your version of Django. For Django select the right one, depending on your version of Django. For Django
1.5.x or below, you'll need to extend one of the following: 1.5.x or below, youll need to extend one of the following:
:: ::
@ -534,8 +534,8 @@ For Django 1.6.x, extend:
templates/adminsortable/edit_inline/stacked.html templates/adminsortable/edit_inline/stacked.html
templates/adminsortable/edit_inline/tabular.html templates/adminsortable/edit_inline/tabular.html
A Special Note About Stacked Inlines... A Special Note About Stacked Inlines
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The height of a stacked inline model can dynamically increase, which can The height of a stacked inline model can dynamically increase, which can
make them difficult to sort. If you anticipate the height of a stacked make them difficult to sort. If you anticipate the height of a stacked
@ -545,7 +545,7 @@ SortableTabularInline instead.
Django-CMS integration Django-CMS integration
~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~
Django-CMS plugins use their own change form, and thus won't Django-CMS plugins use their own change form, and thus wont
automatically include the necessary JavaScript for django-admin-sortable automatically include the necessary JavaScript for django-admin-sortable
to work. Fortunately, this is easy to resolve, as the ``CMSPlugin`` to work. Fortunately, this is easy to resolve, as the ``CMSPlugin``
class allows a change form template to be specified: class allows a change form template to be specified:
@ -575,7 +575,7 @@ class allows a change form template to be specified:
The contents of ``sortable-stacked-inline-change-form.html`` at a The contents of ``sortable-stacked-inline-change-form.html`` at a
minimum need to extend the extrahead block with: minimum need to extend the extrahead block with:
.. code:: html .. code:: html+django
{% extends "admin/cms/page/plugin_change_form.html" %} {% extends "admin/cms/page/plugin_change_form.html" %}
{% load static from staticfiles %} {% load static from staticfiles %}
@ -594,45 +594,45 @@ Sorting within Django-CMS is really only feasible for inline models of a
plugin as Django-CMS already includes sorting for plugin instances. For plugin as Django-CMS already includes sorting for plugin instances. For
tabular inlines, just substitute: tabular inlines, just substitute:
.. code:: html .. code:: html+django
<script src="{% static 'adminsortable/js/admin.sortable.stacked.inlines.js' %}"></script> <script src="{% static 'adminsortable/js/admin.sortable.stacked.inlines.js' %}"></script>
with: with:
.. code:: html .. code:: html+django
<script src="{% static 'adminsortable/js/admin.sortable.tabular.inlines.js' %}"></script> <script src="{% static 'adminsortable/js/admin.sortable.tabular.inlines.js' %}"></script>
Notes Notes
~~~~~ ~~~~~
From ``django-cms 3.x`` the path of change\_form.html has changed. From ``django-cms 3.x`` the path of change_form.html has changed.
Replace the follwing line: Replace the follwing line:
.. code:: html .. code:: html+django
{% extends "admin/cms/page/plugin_change_form.html" %} {% extends "admin/cms/page/plugin_change_form.html" %}
with with
.. code:: html .. code:: html+django
{% extends "admin/cms/page/plugin/change_form.html" %} {% extends "admin/cms/page/plugin/change_form.html" %}
From ``django-admin-sortable 2.0.13`` the ``jquery.django-csrf.js`` was From ``django-admin-sortable 2.0.13`` the ``jquery.django-csrf.js`` was
removed and you have to include the snippet-template. Change the removed and you have to include the snippet-template. Change the
following line: following line:
.. code:: html .. code:: html+django
<script type="text/javascript" src="{% static 'adminsortable/js/jquery.django-csrf.js' %}"></script> <script type="text/javascript" src="{% static 'adminsortable/js/jquery.django-csrf.js' %}"></script>
to to
.. code:: html .. code:: html+django
{% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name='csrftoken' %} {% include 'adminsortable/csrf/jquery.django-csrf.html' with csrf_cookie_name='csrftoken' %}
Please note, if you change the ``CSRF_COOKIE_NAME`` you have to adjust Please note, if you change the ``CSRF_COOKIE_NAME`` you have to adjust
``csrf_cookie_name='YOUR_CSRF_COOKIE_NAME'`` ``csrf_cookie_name='YOUR_CSRF_COOKIE_NAME'``
@ -641,7 +641,7 @@ Rationale
~~~~~~~~~ ~~~~~~~~~
Other projects have added drag-and-drop ordering to the ChangeList view, Other projects have added drag-and-drop ordering to the ChangeList view,
however this introduces a couple of problems... however this introduces a couple of problems
- The ChangeList view supports pagination, which makes drag-and-drop - The ChangeList view supports pagination, which makes drag-and-drop
ordering across pages impossible. ordering across pages impossible.
@ -657,10 +657,12 @@ Status
django-admin-sortable is currently used in production. django-admin-sortable is currently used in production.
What's new in 2.1.2? Whats new in 2.1.3?
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
- Django 2 compatibility - Norwegian and Latvian translations. Credit to
`simenheg <https://github.com/simenheg>`__ and
`peterisb <https://github.com/peterisb>`__ respectively.
Future Future
~~~~~~ ~~~~~~
@ -678,5 +680,5 @@ django-admin-sortable is released under the Apache Public License v2.
:target: https://pypi.python.org/pypi/django-admin-sortable :target: https://pypi.python.org/pypi/django-admin-sortable
.. |Python versions| image:: https://img.shields.io/pypi/pyversions/django-admin-sortable.svg .. |Python versions| image:: https://img.shields.io/pypi/pyversions/django-admin-sortable.svg
:target: https://pypi.python.org/pypi/django-admin-sortable :target: https://pypi.python.org/pypi/django-admin-sortable
.. |Build Status| image:: https://travis-ci.org/iambrandontaylor/django-admin-sortable.svg?branch=master .. |Build Status| image:: https://travis-ci.org/alsoicode/django-admin-sortable.svg?branch=master
:target: https://travis-ci.org/iambrandontaylor/django-admin-sortable :target: https://travis-ci.org/alsoicode/django-admin-sortable

View File

@ -1,4 +1,4 @@
VERSION = (2, 1, 2) VERSION = (2, 1, 3)
DEV_N = None DEV_N = None