Hi,

In your Django application, session middleware is enabled ? [1]

[1] https://docs.djangoproject.com/en/3.0/topics/http/sessions/

On Tue, Feb 25, 2020 at 8:16 AM Guy NANA <[email protected]> wrote:

> I don't understand the first part of your answer : *Make sure your
>> line request.session['ts_dataset_copy'], print anything above it.*
>
>  For sending dataset file from angular app to django, I've used a post
> request.
>
> The matter is that when I send the second http crosss-origin from angular
> app to my django app the previously session's elements that I've stored
> doesn't exist anymore. (I checked the session keys in the
> upload_local_dataset and receive *In upload_local_dataset Session's keys
> : dict_keys(['ts_dataset', 'ts_dataset_copy'])* but in the second views I
> received an empty dict *In cv_classification Session's keys :
> dict_keys([])* so pandas' read_json throws an error *ValueError: Invalid
> file path or buffer object type: *
> How can I save the state of session between two http cross-origin from
> angular app to django app ?
>
> Le mardi 25 février 2020 13:29:53 UTC+1, Pankaj Sharma a écrit :
>
>> Make sure your line request.session['ts_dataset_copy'], print anything
>> above it, also make sure you are using POST method in forms (method =
>> "post")
>>
>> On Tuesday, February 25, 2020 at 3:47:25 AM UTC+5:30, Guy NANA wrote:
>>>
>>> I have an angular frontend app which send file to django backend which
>>> data is setting in django session. After I send a httprequest to django
>>> backend to make ML tratements on that data and get the results. But I've a
>>> 500 sever error: keyerror 'ts_dataset_copy': KeyError: 'ts_dataset_copy'
>>> [24/Feb/2020 18:43:46] "GET /cv_classification/5/FOTS/283/None/0/0
>>> HTTP/1.1" 500 78264. Here are my django code:
>>>
>>> Firstly I upload timeseries dataset file from angular frontend (All
>>> thing is ok)
>>> @csrf_exempt
>>>     def upload_local_dataset(request):
>>>         if request.method == 'POST':
>>>             dataset = pd.read_csv(request.FILES.get('datasetfilepath'),
>>> header=None, index_col=None)
>>>             request.session['ts_datset'] = dataset.to_json(orient=
>>> 'values')
>>>             request.session['ts_dataset_copy'] = dataset.to_json(orient=
>>> 'values')
>>>
>>>             return HttpResponse(dataset.to_json(orient='values'))
>>>
>>>
>>>
>>> # second httrequest that throws a server internal error
>>>
>>>     def cv_classification(request, kfolds, dissimilarity_func,
>>> windows_length=0, noisy_law="", mu=0,
>>>
>>>         std=0):
>>>             noisy_law = noisy_law.lower()
>>>             df = pd.read_json(request.session['ts_dataset_copy'], orient
>>> ='values')
>>>             predictions = cv_classify(df, kfolds, dissimilarity_func,
>>> windows_length, noisy_law, mu, std)
>>>             return JsonResponse(predictions, safe=False)
>>>
>>>
>>>
>>> Thanks for your help!
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c0d3a833-15f2-415f-b4e0-c05951f523f0%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/c0d3a833-15f2-415f-b4e0-c05951f523f0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Juan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJK1Jg26mZp4wdq9tmiAmhUCRY4vZk5krLrBaP3hSwkBWh%3DDnA%40mail.gmail.com.

Reply via email to