Reputation: 1
Dont know how to do this: I have program, that create data with POST and have some fields, like:
create_data:
id:
value:
Need check field "value" between current and previous POST, and if previous "value" more then current "value" - prevent create current POST with error.
Upvotes: 0
Views: 209
Reputation: 7678
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.
Upvotes: 1