{"id":20601497,"url":"https://github.com/incuna/django-orderable","last_synced_at":"2025-08-02T02:12:11.263Z","repository":{"id":3161953,"uuid":"4192553","full_name":"incuna/django-orderable","owner":"incuna","description":"Add manual sort order to Django objects via an abstract base class and admin classes","archived":false,"fork":false,"pushed_at":"2023-06-29T19:53:38.000Z","size":158,"stargazers_count":40,"open_issues_count":12,"forks_count":19,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-06-30T14:08:49.178Z","etag":null,"topics":["django","python","sort-order"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/incuna.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2012-05-01T13:38:15.000Z","updated_at":"2024-11-28T16:30:02.000Z","dependencies_parsed_at":"2023-07-06T16:32:17.328Z","dependency_job_id":null,"html_url":"https://github.com/incuna/django-orderable","commit_stats":{"total_commits":177,"total_committers":15,"mean_commits":11.8,"dds":0.6666666666666667,"last_synced_commit":"9eebdae3b1b3a9f0a380542520e78d57114cbd20"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/incuna/django-orderable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/incuna%2Fdjango-orderable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/incuna%2Fdjango-orderable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/incuna%2Fdjango-orderable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/incuna%2Fdjango-orderable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/incuna","download_url":"https://codeload.github.com/incuna/django-orderable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/incuna%2Fdjango-orderable/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268326739,"owners_count":24232496,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["django","python","sort-order"],"created_at":"2024-11-16T09:10:39.391Z","updated_at":"2025-08-02T02:12:11.231Z","avatar_url":"https://github.com/incuna.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django Orderable\n\n\nAdd manual sort order to Django objects via an abstract base class and admin classes. Project includes:\n\n* Abstract base Model\n* Admin class\n* Inline admin class\n* Admin templates\n\n\n## Demo\n\n\n![django-orderable demo](https://cloud.githubusercontent.com/assets/30606/6326221/667992e0-bb47-11e4-923e-29334573ff5c.gif)\n\n## Installation\n\n\nGrab from the PyPI:\n\n    pip install django-orderable\n\n\nAdd to your INSTALLED_APPS:\n\n    ...\n    'orderable',\n    ...\n\nSubclass the Orderable class:\n\n    from orderable.models import Orderable\n\n\n    class Book(Orderable):\n        ...\n\nSubclass the appropriate Orderable admin classes:\n\n    from orderable.admin import OrderableAdmin, OrderableTabularInline\n\n\n    class SomeInlineClass(OrderableTabularInline):\n        ...\n\n    class SomeAdminClass(OrderableAdmin):\n        list_display = ('__unicode__', 'sort_order_display')\n        ...\n\n\njQuery and jQuery UI are used in the Admin for the draggable UI. You may override the versions with your own (rather than using Google's CDN):\n\n    class SomeAdminClass(OrderableAdmin):\n        class Media:\n            extend = False\n            js = (\n                'path/to/jquery.js',\n                'path/to/jquery.ui.js',\n            )\n\n\n## Notes\n\n### `class Meta`\n\nIf your subclass of `Orderable` defines [`class Meta`](https://docs.djangoproject.com/en/2.0/ref/models/options/) then make sure it subclasses `Orderable.Meta` one so the model is sorted by `sort_order`. ie:\n\n    class MyOrderable(Orderable):\n        class Meta(Orderable.Meta):\n            ...\n\n### Custom Managers\n\nSimilarly, if your model has a custom manager, subclass `orderable.managers.OrderableManager` instead of `django.db.models.Manager`.\n\n### Transactions\n\nSaving orderable models invokes a fair number of database queries, and in order\nto avoid race conditions should be run in a transaction.\n\n### Adding Orderable to Existing Models\n\nYou will need to populate the required `sort_order` field. Typically this is\ndone by adding the field in one migration with a default of `0`, then creating\na data migration to set the value to that of its primary key:\n\n\n    for obj in orm['appname.Model'].objects.all():\n        obj.sort_order = obj.pk\n        obj.save()\n\n\n### Multiple Models using Orderable\n\nWhen multiple models inherit from Orderable the `next()` and `previous()`\nmethods will look for the next/previous model with a sort order. However you'll\nlikely want to have the various sort orders determined by a foreign key or some\nother predicate. The easiest way (currently) is to override the method in\nquestion.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincuna%2Fdjango-orderable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fincuna%2Fdjango-orderable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fincuna%2Fdjango-orderable/lists"}