Is there a way to pass request
object from one view to another? Or do I have to dissect the request into individual parts or use request.__dict__
and pass those?
Currenlty, because the request cannot be serialized, the below code:
def explorer(request):
collect_activities_init(request)
return render(request, 'explorer/explorer.html')
def collect_activities_init(request):
task = collect_activities.delay(request)
return JsonResponse({'status_url': reverse('explorer:collect_activities_status', kwargs={'task_id': task.id})})
@celery.task(bind=True)
def collect_activities(self, request):
api = StravaApi()
code = request.GET.get('code', '') # extract code from redirect URL query string
Will give:
WSGIRequest: GET '/explorer/?state=&code=3ba4hgh5ad99ea3cf8e52d8&scope='> is not JSON serializable
But I need to have the request data from the first function in the last one, because its code extracts some data from the request.