mirror of
https://github.com/jazzband/django-admin-sortable.git
synced 2026-03-17 06:20:33 +00:00
Compare commits
11 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9c1f3e0c4 | ||
|
|
15766e79d8 | ||
|
|
844b51456f | ||
|
|
b0c25c303c | ||
|
|
c44edfe40a | ||
|
|
3ae816d64d | ||
|
|
aaaa92ba37 | ||
|
|
508e9f35d6 | ||
|
|
c0874bfd7e | ||
|
|
5aeaa27f5b | ||
|
|
f9a896f469 |
7 changed files with 73 additions and 41 deletions
52
.github/workflows/tests.yml
vendored
Normal file
52
.github/workflows/tests.yml
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
---
|
||||||
|
name: Tests
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
name: Python ${{ matrix.python-version }}, Django ${{ matrix.django-version }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
python-version:
|
||||||
|
- "3.6"
|
||||||
|
- "3.7"
|
||||||
|
- "3.8"
|
||||||
|
- "3.9"
|
||||||
|
django-version:
|
||||||
|
- "2.2.17" # first version to support Python 3.9
|
||||||
|
- "3.1.3" # first version to support Python 3.9
|
||||||
|
- "3.2.0"
|
||||||
|
include:
|
||||||
|
- python-version: "3.8"
|
||||||
|
django-version: "4.0.0"
|
||||||
|
- python-version: "3.9"
|
||||||
|
django-version: "4.0.0"
|
||||||
|
- python-version: "3.10"
|
||||||
|
django-version: "3.2.9" # first version to support Python 3.10
|
||||||
|
- python-version: "3.10"
|
||||||
|
django-version: "4.0.0"
|
||||||
|
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip wheel setuptools
|
||||||
|
python -m pip install --upgrade "django~=${{ matrix.django-version}}"
|
||||||
|
- name: Run tests
|
||||||
|
run: python manage.py test
|
||||||
|
working-directory: sample_project
|
||||||
24
.travis.yml
24
.travis.yml
|
|
@ -1,24 +0,0 @@
|
||||||
arch:
|
|
||||||
- amd64
|
|
||||||
- ppc64le
|
|
||||||
language: python
|
|
||||||
python:
|
|
||||||
- "3.6"
|
|
||||||
- "3.7"
|
|
||||||
- "3.8"
|
|
||||||
- "3.9"
|
|
||||||
env:
|
|
||||||
- DJANGO_VERSION=2.2 SAMPLE_PROJECT=sample_project
|
|
||||||
- DJANGO_VERSION=3.1 SAMPLE_PROJECT=sample_project
|
|
||||||
- DJANGO_VERSION=3.2 SAMPLE_PROJECT=sample_project
|
|
||||||
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- develop
|
|
||||||
|
|
||||||
install:
|
|
||||||
- pip install django==$DJANGO_VERSION
|
|
||||||
|
|
||||||
script:
|
|
||||||
- cd $SAMPLE_PROJECT
|
|
||||||
- python manage.py test
|
|
||||||
24
README.md
24
README.md
|
|
@ -22,7 +22,9 @@ Sorting inlines:
|
||||||

|

|
||||||
|
|
||||||
## Supported Django Versions
|
## Supported Django Versions
|
||||||
For Django 3 use the latest version
|
For Django 4 use the latest version
|
||||||
|
|
||||||
|
For Django 3 use 2.2.4
|
||||||
|
|
||||||
For Django 1.8.x < 3.0, use 2.1.8.
|
For Django 1.8.x < 3.0, use 2.1.8.
|
||||||
|
|
||||||
|
|
@ -85,14 +87,14 @@ Inlines may be drag-and-dropped into any order directly from the change form.
|
||||||
To add "sortability" to a model, you need to inherit `SortableMixin` and at minimum, define:
|
To add "sortability" to a model, you need to inherit `SortableMixin` and at minimum, define:
|
||||||
|
|
||||||
- The field which should be used for `Meta.ordering`, which must resolve to one of the integer fields defined in Django's ORM:
|
- The field which should be used for `Meta.ordering`, which must resolve to one of the integer fields defined in Django's ORM:
|
||||||
- `PositiveIntegerField`
|
- `PositiveIntegerField`
|
||||||
- `IntegerField`
|
- `IntegerField`
|
||||||
- `PositiveSmallIntegerField`
|
- `PositiveSmallIntegerField`
|
||||||
- `SmallIntegerField`
|
- `SmallIntegerField`
|
||||||
- `BigIntegerField`
|
- `BigIntegerField`
|
||||||
|
|
||||||
- `Meta.ordering` **must only contain one value**, otherwise, your objects will not be sorted correctly.
|
- ⚠️ `Meta.ordering` **must only contain one value**, otherwise, your objects will not be sorted correctly.
|
||||||
- **IMPORTANT**: You must name the field you use for ordering something other than "order_field" as this name is reserved by the `SortableMixin` class.
|
- ⚠️ **IMPORTANT**: You must name the field you use for ordering something other than "order_field" as this name is reserved by the `SortableMixin` class.
|
||||||
- It is recommended that you set `editable=False` and `db_index=True` on the field defined in `Meta.ordering` for a seamless Django admin experience and faster lookups on the objects.
|
- It is recommended that you set `editable=False` and `db_index=True` on the field defined in `Meta.ordering` for a seamless Django admin experience and faster lookups on the objects.
|
||||||
|
|
||||||
Sample Model:
|
Sample Model:
|
||||||
|
|
@ -442,7 +444,7 @@ It is also possible to sort a subset of objects in your model by adding a `sorti
|
||||||
#### Self-Referential SortableForeignKey
|
#### Self-Referential SortableForeignKey
|
||||||
You can specify a self-referential SortableForeignKey field, however 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.
|
You can specify a self-referential SortableForeignKey field, however 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.
|
||||||
|
|
||||||
##### Important!
|
##### ⚠️ Important!
|
||||||
django-admin-sortable 1.6.6 introduced a backwards-incompatible change for `sorting_filters`. Previously this attribute was defined as a dictionary, so you'll need to change your values over to the new tuple-based format.
|
django-admin-sortable 1.6.6 introduced a backwards-incompatible change for `sorting_filters`. Previously this attribute was defined as a dictionary, so you'll need to change your values over to the new tuple-based format.
|
||||||
|
|
||||||
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 on the Board of Directors and some not, and you need to sort them independently.
|
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 on the Board of Directors and some not, and you need to sort them independently.
|
||||||
|
|
@ -668,8 +670,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.2.3?
|
### What's new in 2.3.0?
|
||||||
- Updated inline sortable templates to fix FontAwesome icon visibility and be compatible with Django 2 & 3.
|
- Django 4 compatibility
|
||||||
|
|
||||||
### 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.
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@ Sorting inlines:
|
||||||
Supported Django Versions
|
Supported Django Versions
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
For Django 3 use the latest version
|
For Django 4 use the latest version
|
||||||
|
|
||||||
|
For Django 3 use 2.2.4
|
||||||
|
|
||||||
For Django 1.8.x < 3.0, use 2.1.8.
|
For Django 1.8.x < 3.0, use 2.1.8.
|
||||||
|
|
||||||
|
|
@ -751,10 +753,10 @@ Status
|
||||||
|
|
||||||
django-admin-sortable is currently used in production.
|
django-admin-sortable is currently used in production.
|
||||||
|
|
||||||
What’s new in 2.2.3?
|
What’s new in 2.3.0?
|
||||||
~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
- Updated inline sortable templates to fix FontAwesome icon visibility and be compatible with Django 2 & 3.
|
- Django 4 compatibility
|
||||||
|
|
||||||
Future
|
Future
|
||||||
~~~~~~
|
~~~~~~
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
VERSION = (2, 2, 4)
|
VERSION = (2, 3, 0)
|
||||||
DEV_N = None
|
DEV_N = None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import json
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import re_path
|
|
||||||
from django.contrib.admin import ModelAdmin, TabularInline, StackedInline
|
from django.contrib.admin import ModelAdmin, TabularInline, StackedInline
|
||||||
from django.contrib.admin.options import InlineModelAdmin
|
from django.contrib.admin.options import InlineModelAdmin
|
||||||
from django.contrib.admin.views.main import IGNORED_PARAMS, PAGE_VAR
|
from django.contrib.admin.views.main import IGNORED_PARAMS, PAGE_VAR
|
||||||
|
|
@ -14,6 +13,7 @@ from django.db import transaction
|
||||||
from django.http import JsonResponse
|
from django.http import JsonResponse
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.template.defaultfilters import capfirst
|
from django.template.defaultfilters import capfirst
|
||||||
|
from django.urls import re_path
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django.views.decorators.http import require_POST
|
from django.views.decorators.http import require_POST
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -1,6 +1,6 @@
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
with open('README.rst') as readme_file:
|
with open('README.rst', encoding='utf8') as readme_file:
|
||||||
README = readme_file.read()
|
README = readme_file.read()
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue