{"id":13532148,"url":"https://github.com/elton2048/wagtail-orderable","last_synced_at":"2025-04-08T03:12:27.230Z","repository":{"id":33919386,"uuid":"163503604","full_name":"elton2048/wagtail-orderable","owner":"elton2048","description":"Wagtail mixin support for drag-and-drop ordering in admin panel","archived":false,"fork":false,"pushed_at":"2024-06-14T08:38:15.000Z","size":47,"stargazers_count":66,"open_issues_count":12,"forks_count":32,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-31T16:18:56.194Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elton2048.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-29T10:54:18.000Z","updated_at":"2024-11-29T02:29:37.000Z","dependencies_parsed_at":"2024-06-19T05:26:01.678Z","dependency_job_id":"95e24a45-33bd-4427-87f4-7919186ad846","html_url":"https://github.com/elton2048/wagtail-orderable","commit_stats":{"total_commits":34,"total_committers":14,"mean_commits":"2.4285714285714284","dds":0.6764705882352942,"last_synced_commit":"705186396f4ca511d01fd5a1a89b111aa72ac7ea"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elton2048%2Fwagtail-orderable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elton2048%2Fwagtail-orderable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elton2048%2Fwagtail-orderable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elton2048%2Fwagtail-orderable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elton2048","download_url":"https://codeload.github.com/elton2048/wagtail-orderable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247767236,"owners_count":20992548,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:01:08.562Z","updated_at":"2025-04-08T03:12:27.205Z","avatar_url":"https://github.com/elton2048.png","language":"Python","funding_links":[],"categories":["Apps"],"sub_categories":["Misc"],"readme":"# Wagtail Orderable\n\nSimple orderable mixin to add drag-and-drop ordering support to the `ModelAdmin` listing view.\n\nIt attempts to provide the [feature request](https://github.com/wagtail/wagtail/issues/2941) in Wagtail project without modifying the project code as it seems not a high priority item for the project.\n\n### Installation\n\nInstall the package\n```\npip install wagtail-orderable\n```\n\n### Settings\nIn your settings file, add `wagtailorderable` to `INSTALLED_APPS`:\n```python\nINSTALLED_APPS = [\n    # ...\n    'wagtailorderable',\n    # ...\n]\n```\n\n### Usage\n\n#### Extend with `Orderable` (optional)\n\nTo apply the orderable feature, you can extend your model with `Orderable` which will add\na `sort_order` `IntegerField` to your model but if you already have a field to store\nan index value, **this is not required**.\n\n```python\nfrom django.db import models\n\nfrom wagtailorderable.models import Orderable\n\n\nclass YourModel(Orderable):\n    title = models.CharField(max_length=200)\n```\n\nOf course you can apply it to Wagtail's `Page` model.\n```python\nfrom wagtail import fields\nfrom wagtail.models import Page\n\nfrom wagtailorderable.models import Orderable\n\n\nclass YourModel(Page, Orderable):\n    description = fields.RichTextField(blank=True)\n```\n\n\nOr just use your model with your personal ordering field.\n\n```python\nfrom django.db import models\n\n\nclass YourOtherModel(models.Model):\n    title = models.CharField(max_length=200)\n    my_custom_order_field = models.IntegerField(null=False, blank=True, default=0, editable=False)\n```\n\nNote that `Orderable` also exists in `wagtail.models`, **DO NOT** use that as the mixins require the model from the same package.\n\nTo apply the feature support in admin panel. In `wagtail_hooks.py`:\n```python\nfrom wagtail.contrib.modeladmin.options import (\n    ModelAdmin, modeladmin_register)\n\nfrom wagtailorderable.modeladmin.mixins import OrderableMixin\n\nfrom .models import YourModel, YourOtherModel\n\n\nclass YourModelAdmin(OrderableMixin, ModelAdmin):\n    model = YourModel\n\n\nclass YourOtherModelAdmin(OrderableMixin, ModelAdmin):\n    model = YourOtherModel\n    sort_order_field = 'my_custom_order_field'\n\nmodeladmin_register(YourModelAdmin)\nmodeladmin_register(YourOtherModelAdmin)\n```\n\nNote that `sort_order_field` is optional if you extend your model with `Orderable`\nor if your Model has a `sort_order_field` attribute.\n\nFinally, collect the corresponding static file by running\n```shell\npython manage.py collectstatic\n```\nin your project.\n\n### Change Log\n\n1.2.0\n---\n- Updated documentation for wagtail 4.0 support\n- Updated workflow action versions\n- Allow wagtail v4.1+ (drops ability to use on a wagtail site version earlier than v4.1)\n- Allow Wagtail v5 and Django v4.2\n\n1.1.0\n---\n- Extending `Orderable` is no more mandatory if you want to use your own order field (#27)\n- Add `Orderable.get_sort_order_max()` to get the max \"order\" when instance is being created (#27)\n- Fix keeping current filters when sorting was reset (#27)\n- Fix class names (`get_extra_class_names_for_field_col` parameters were inverted) (#27)\n- Fix CSS which had SCSS syntax (#27)\n\n1.0.4\n---\n- Provide Github Actions script to build and publish package in PyPI\n- Add support for Wagtail 3.0 and drop support for all Wagtail versions\n   before 2.15 (#32)\n- Use `pk` instead of `id` for duplicate positions (#31)\n\n1.0.3\n---\n- Fix `TypeError` when creating the first Orderable object (#21)\n\n1.0.2\n---\n- Fix `sort_order` duplication for items\n- Fix wrong `return` syntax\n\n1.0.1\n---\n- `get_list_display` handles any iterable\n- Support for filters in ModelAdmin\n- Style updated\n\n### Acknowledgement\nMost of the contribution comes from this [commit](https://github.com/rkhleics/wagtail/commit/08df07689af1096ce4a6fa96325dbfb7fab9240d) which attempts to integrate the solution in Wagtail project. Though it is not being used in Wagtail now it provides great skeleton for the feature which helps me created this mixin.\n\nThanks the contribution from [Andy Babic](https://github.com/ababic).\n\nContirbution for this project are all welcome :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felton2048%2Fwagtail-orderable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felton2048%2Fwagtail-orderable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felton2048%2Fwagtail-orderable/lists"}