For fetching data it is recommended to usually use a GET
and for submitting a form, a POST
. How about for the following function, which 'checks out' an item:
@validate_credentials
@csrf_exempt
@acceptable_methods(???)
def cue_checkout(request, cue_id, user=None, checkout=True):
cue = Cue.objects.filter(pk=cue_id, user=user)
if not cue.exists():
return HttpResponseForbidden('Invalid Cue supplied.')
cue = cue[0]
CueAssignment.objects.create(cue=cue, user=user, checkout_timestamp=timezone.now())
return HttpResponse()
I'm thinking since we're modifying data it should be a POST
, but could someone please explain what the correct method would be here and why?