-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
django-hashid-field integration #257
Comments
The way this can be solved is to subclass from adminsortable2.admin import SortableAdminMixin
from django.http.response import (
HttpResponse,
HttpResponseBadRequest,
HttpResponseForbidden,
HttpResponseNotAllowed,
)
class HashIdSortableAdminMixin(SortableAdminMixin):
"""A mixin enabling sorting functionalities."""
encoder = MyEncoder
def update_order(self, request):
"""Update items order."""
if not request.is_ajax() or request.method != "POST":
return HttpResponseBadRequest("Not an XMLHttpRequest")
if request.method != "POST":
return HttpResponseNotAllowed("Must be a POST request")
if not self.has_change_permission(request):
return HttpResponseForbidden("Missing permissions to perform this request")
startorder = int(request.POST.get("startorder"))
endorder = int(request.POST.get("endorder", 0))
moved_items = list(self._move_item(request, startorder, endorder))
return HttpResponse(
json.dumps(moved_items, cls=self.encoder),
content_type="application/json;charset=UTF-8",
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I'm encountering an error in the console logs on sorting management on a model with hashid which, however, does not seem to compromise the real functioning of sorting
The text was updated successfully, but these errors were encountered: