Version bump to 2.0.12.

Updated docs.
master
Brandon Taylor 2016-02-23 13:35:21 -05:00
parent 80719bace9
commit 70549b2517
3 changed files with 51 additions and 50 deletions

View File

@ -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) [![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.11 Current version: 2.0.12
This project makes it easy to add drag-and-drop ordering to any model in 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, Django admin. Inlines for a sortable model may also be made sortable,
@ -497,8 +497,8 @@ ordering on top of that just seemed a little much in my opinion.
django-admin-sortable is currently used in production. django-admin-sortable is currently used in production.
### What's new in 2.0.11? ### What's new in 2.0.12?
- Custom [CSRF_COOKIE_NAME](https://docs.djangoproject.com/en/1.9/ref/settings/#csrf-cookie-name) is now supported. Thanks [@BUHARDI](https://github.com/BUHARDI) for reporting the issue. - Fixed an issue with CSRF_COOKIE_NAME not being passed correctly to inlines. Thanks [@Hovercross](https://github.com/Hovercross) for reporting the issue.
### Future ### Future

View File

@ -3,7 +3,7 @@ Django Admin Sortable
|Build Status| |Build Status|
Current version: 2.0.11 Current version: 2.0.12
This project makes it easy to add drag-and-drop ordering to any model in 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, Django admin. Inlines for a sortable model may also be made sortable,
@ -113,18 +113,20 @@ and at minimum, define:
Sample Model: Sample Model:
:: .. code:: python
# models.py # models.py
from adminsortable.models import SortableMixin from adminsortable.models import SortableMixin
class MySortableClass(SortableMixin): class MySortableClass(SortableMixin):
title = models.CharField(max_length=50)
class Meta: class Meta:
verbose_name = 'My Sortable Class' verbose_name = 'My Sortable Class'
verbose_name_plural = 'My Sortable Classes' verbose_name_plural = 'My Sortable Classes'
ordering = ['the_order'] ordering = ['the_order']
title = models.CharField(max_length=50)
# define the field the model should be ordered by # define the field the model should be ordered by
the_order = models.PositiveIntegerField(default=0, editable=False, db_index=True) the_order = models.PositiveIntegerField(default=0, editable=False, db_index=True)
@ -139,7 +141,7 @@ 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, here's how you would
set up your models and admin options: set up your models and admin options:
:: .. code:: python
# models.py # models.py
from adminsortable.fields import SortableForeignKey from adminsortable.fields import SortableForeignKey
@ -179,7 +181,7 @@ Sometimes you might have a parent model that is not sortable, but has
child models that are. In that case define your models and admin options child models that are. In that case define your models and admin options
as such: as such:
:: .. code:: python
from adminsortable.fields import SortableForeignKey from adminsortable.fields import SortableForeignKey
@ -236,7 +238,7 @@ a permanent thing.
Please note however that the ``Sortable`` class still contains the Please note however that the ``Sortable`` class still contains the
hard-coded ``order`` field, and meta inheritance requirements: hard-coded ``order`` field, and meta inheritance requirements:
:: .. code:: python
# legacy model definition # legacy model definition
@ -256,7 +258,7 @@ Model Instance Methods
Each instance of a sortable model has two convenience methods to get the Each instance of a sortable model has two convenience methods to get the
next or previous instance: next or previous instance:
:: .. code:: python
.get_next() .get_next()
.get_previous() .get_previous()
@ -281,14 +283,14 @@ following data:
If you wish to override this behavior, pass in: If you wish to override this behavior, pass in:
``filter_on_sortable_fk=False``: ``filter_on_sortable_fk=False``:
:: .. code:: python
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
your_instance.get_next(extra_filters={'title__icontains': 'blue'}) your_instance.get_next(extra_filters={'title__icontains': 'blue'})
@ -306,7 +308,7 @@ create a data migration in order to add the appropriate values for the
Example assuming a model named "Category": Example assuming a model named "Category":
:: .. code:: python
def forwards(self, orm): def forwards(self, orm):
for index, category in enumerate(orm.Category.objects.all()): for index, category in enumerate(orm.Category.objects.all()):
@ -332,7 +334,7 @@ Django Admin Integration
To enable sorting in the admin, you need to inherit from To enable sorting in the admin, you need to inherit from
``SortableAdmin``: ``SortableAdmin``:
:: .. code:: python
from django.contrib import admin from django.contrib import admin
from myapp.models import MySortableClass from myapp.models import MySortableClass
@ -346,7 +348,7 @@ To enable sorting in the admin, you need to inherit from
To enable sorting on TabularInline models, you need to inherit from To enable sorting on TabularInline models, you need to inherit from
SortableTabularInline: SortableTabularInline:
:: .. code:: python
from adminsortable.admin import SortableTabularInline from adminsortable.admin import SortableTabularInline
@ -356,7 +358,7 @@ SortableTabularInline:
To enable sorting on StackedInline models, you need to inherit from To enable sorting on StackedInline models, you need to inherit from
SortableStackedInline: SortableStackedInline:
:: .. code:: python
from adminsortable.admin import SortableStackedInline from adminsortable.admin import SortableStackedInline
@ -365,7 +367,7 @@ SortableStackedInline:
There are also generic equivalents that you can inherit from: There are also generic equivalents that you can inherit from:
:: .. code:: python
from adminsortable.admin import (SortableGenericTabularInline, from adminsortable.admin import (SortableGenericTabularInline,
SortableGenericStackedInline) SortableGenericStackedInline)
@ -374,7 +376,7 @@ There are also generic equivalents that you can inherit from:
If your parent model is *not* sortable, but has child inlines that are, If your parent model is *not* sortable, but has child inlines that are,
your parent model needs to inherit from ``NonSortableParentAdmin``: your parent model needs to inherit from ``NonSortableParentAdmin``:
:: .. code:: python
from adminsortable.admin import (NonSortableParentAdmin, from adminsortable.admin import (NonSortableParentAdmin,
SortableTabularInline) SortableTabularInline)
@ -404,7 +406,7 @@ Overriding ``queryset()`` for an inline model
This is a special case, which requires a few lines of extra code to This is a special case, which requires a few lines of extra code to
properly determine the sortability of your model. Example: properly determine the sortability of your model. Example:
:: .. code:: python
# add this import to your admin.py # add this import to your admin.py
from adminsortable.utils import get_is_sortable from adminsortable.utils import get_is_sortable
@ -464,7 +466,7 @@ 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.
:: .. code:: python
class Person(Sortable): class Person(Sortable):
class Meta(Sortable.Meta): class Meta(Sortable.Meta):
@ -492,14 +494,14 @@ 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:
:: .. code:: python
change_form_template_extends change_form_template_extends
change_list_template_extends change_list_template_extends
These attributes have default values of: These attributes have default values of:
:: .. 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'
@ -536,7 +538,7 @@ 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:
:: .. code:: python
# example plugin # example plugin
from cms.plugin_base import CMSPluginBase from cms.plugin_base import CMSPluginBase
@ -561,7 +563,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
{% extends "admin/cms/page/plugin_change_form.html" %} {% extends "admin/cms/page/plugin_change_form.html" %}
{% load static from staticfiles %} {% load static from staticfiles %}
@ -579,13 +581,13 @@ 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
<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
<script src="{% static 'adminsortable/js/admin.sortable.tabular.inlines.js' %}"></script> <script src="{% static 'adminsortable/js/admin.sortable.tabular.inlines.js' %}"></script>
@ -609,12 +611,11 @@ Status
django-admin-sortable is currently used in production. django-admin-sortable is currently used in production.
What's new in 2.0.11? What's new in 2.0.12?
~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~
- Custom - Fixed an issue with CSRF\_COOKIE\_NAME not being passed correctly to
`CSRF\_COOKIE\_NAME <https://docs.djangoproject.com/en/1.9/ref/settings/#csrf-cookie-name>`__ inlines. Thanks [@Hovercross](https://github.com/Hovercross) for
is now supported. Thanks [@BUHARDI](https://github.com/BUHARDI) for
reporting the issue. reporting the issue.
Future Future

View File

@ -1,4 +1,4 @@
VERSION = (2, 0, 11) VERSION = (2, 0, 12)
DEV_N = None DEV_N = None