Skip to content

Commit

Permalink
Bump to version 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Jun 22, 2022
1 parent 7ce50a2 commit 22288ad
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Release history of [django-admin-sortable2](https://github.com/jrief/django-admin-sortable2/)

### 2.1
- Introduce classes `adminsortable2.admin.SortableStackedInline` and `adminsortable2.admin.SortableTabularInline`
to resort items to the begin or end of the list of those inlines.
- Add support for Django-4.1.

### 2.0.5
- Fix: When using an `InlineAdmin` with a self defined form, the default ordering
has been ignored.
Expand Down
2 changes: 1 addition & 1 deletion adminsortable2/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.0.5'
__version__ = '2.1'
Binary file modified docs/source/_static/stacked-inline-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/_static/tabular-inline-view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 27 additions & 3 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,18 @@ If a model on the same page has a parent model, these are called inlines. Suppos
model for chapters and want to edit the chapter together with the book's title using the same
editor, then Django admin offers the classes :class:`~django.contrib.admin.StackedInline` and
:class:`~django.contrib.admin.TabularInline`. To make these inline admin interfaces sortable,
we simple use the mixin class :class:`adminsortable2.admin.SortableAdminMixin`. Example:
we simple use the mixin class :class:`adminsortable2.admin.SortableAdminMixin`.

Example:

.. code-block:: python
...
from adminsortable2.admin import SortableStackedInline
from myapp.models import Chapter
class ChapterStackedInline(SortableInlineAdminMixin, admin.StackedInline):
class ChapterStackedInline(SortableStackedInline):
model = Chapter
@admin.register(SortableBook)
Expand All @@ -171,7 +175,27 @@ For stacked inlines, the editor for the book's detail view looks like:
:width: 800
:alt: Stacked Inline View

If we instead use the tabluar inline class, then the editor for the book's detail view looks like:
.. note:: Since version 2.1, two buttons have been added to the draggable area above each inline
form. They serve to move that edited item to the begin or end of the list of inlines.

If we instead want to use the tabluar inline class, then modify the code from above to

.. code-block:: python
...
from adminsortable2.admin import SortableTabularInline
from myapp.models import Chapter
class ChapterTabularInline(SortableTabularInline):
model = Chapter
@admin.register(SortableBook)
class SortableBookAdmin(SortableAdminMixin, admin.ModelAdmin):
...
inlines = [ChapterTabularInline]
the editor for the book's detail view then looks like:

.. image:: _static/tabular-inline-view.png
:width: 800
Expand Down

0 comments on commit 22288ad

Please sign in to comment.