[Fixed]-Django Rest Framework. Check difference between fields value for two POSTs

1👍

You can save the POST data in a session.
So you can compare values between POSTS.

from django.http import HttpResponse, HttpResponseForbidden

def a_view(request):
    last_post_value = request.session.get('value')
    current_post_value = request.POST.get('value')
    if last_post_value > current_post_value:
        return HttpResponseForbidden()
    request.session['value'] = current_post_value
    return HttpResponse()

You can use models to save your data as well.

Leave a comment