You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
depot_django/DepoT/mixins/crudListViewMixin.py

21 lines
857 B
Python

from django.http import JsonResponse
from django.shortcuts import get_object_or_404
class CRUDListViewMixin:
...
# def post(self, request, *args, **kwargs):
# if request.headers.get('X-Requested-With') == 'XMLHttpRequest':
# object_id = request.POST.get('object_id')
# obj = get_object_or_404(self.model, id=object_id)
# return JsonResponse(self.get_object_data(obj))
# else:
# return self.handle_form_submission(request, *args, **kwargs)
# def get_object_data(self, obj):
# """Override this method in child views to specify which data to return"""
# raise NotImplementedError
#
# def handle_form_submission(self, request, *args, **kwargs):
# """Override this method in child views to handle form submission"""
# raise NotImplementedError