1๐
โ
You need to write a custom decorator to handle the situation.
You can read more about Decorators here: https://docs.djangoproject.com/en/dev/topics/http/decorators/
For example the csrf_exempt
decorator allows a request to be processed without the csrf token facility in forms, very useful for JSON based requests.
@csrf_exempt
def new(request):
if request.method == 'POST':
json_data = simplejson.loads(request.raw_post_data)
try:
Similarly have a custom decorator for ensuring cooking and use it as:
@ensure_cookie
def new(request):
...
Writing custom decorators: How to write a custom decorator in django?
๐คredDragonzz
0๐
You can put this code in process_request or process_view method in custom middleware.
๐คkobuz
- [Answer]-Django annotate count doesn't seem to be counting
- [Answer]-Django HTTP Post Request from iOS
- [Answer]-Using the same cache for two sites
Source:stackexchange.com