1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from django.http import HttpResponseBadRequest
def id_in_get_or_post_required(func):
"""
ID in request GET or POST required decorator
use it in your views:
@id_in_get_or_post_required
def my_view(request):
....
"""
def wrapper(request, *args, **kwargs):
if request.GET.get('id', request.POST.get('id', False)):
return func(request, *args, **kwargs)
return HttpResponseBadRequest()
return wrapper
|
More like this
- prevent GET or POST requests by jerzyk 4 years, 2 months ago
- PK->objects in view signature by AdamKG 3 years, 10 months ago
- View Permission Decorator Helper by jgeewax 3 years, 7 months ago
- Get boolean value from request send by Ajax by zalun 2 years, 7 months ago
- Owner required decorator by polarbear 3 years, 7 months ago
Comments