I think the primary suggestion would be to not use global variables. Is there any way you could re-implement the function without using those global variables? Maybe creating a variable in the settings file for you to use? If you can’t, is there possibly a problem with the get_wb_pdf_as_zip function?
As an aside, I also suggest using render(request, template_name, context_dict) instead of render_to_response(). From: [email protected] [mailto:[email protected]] On Behalf Of ?????? ??????? Sent: Tuesday, January 23, 2018 5:48 AM To: Django users Subject: Strange the global variable behavior Hi there. Could someone explain what happens. I had a little project on Python 2.7 and decided to move it on 3.6. Everything has gone by perfectly. The project works well as before but there is one exception noticed by me: the global statement works not always. The code below doesn't update the global variable zip_file_name and I can't grasp why. Any suggestions. zip_file_name = os.path.join(MEDIA_ROOT, 'wb`s.zip') file_list = [] @permission_required("wb_search.change_wbsearch", login_url='access_denied') @csrf_exempt def input_data_form(request): global zip_file_name, file_list if request.method == 'POST': form = WbSearchForm(request.POST) if form.is_valid(): text = request.POST['wbs_nums'] picked = form.cleaned_data.get('category') try: wb_nums = process_input(text, LENGTH_OF_STR_TO_PROCESS) zip_file_name, file_list = get_wb_pdf_as_zip(wb_nums, picked) m = SearchHistory(user=str(request.user), curr_date=datetime.now(), list_desired_docs=', '.join([str(rec[0]) for rec in file_list])) m.save() return HttpResponseRedirect('/wb_search/search_finished/') except NoDataToSearch: return HttpResponseRedirect('/wb_search/wb_search_incorrect_data/') else: return HttpResponseRedirect('/wb_search/wb_search_incorrect_data/') else: form = WbSearchForm() # context = context.update(csrf(request)) return render_to_response('wb_search_input_data_form.html', {'form': form, 'title': 'Номера для поиска', 'header': 'Поиск PDF файлов вэйбилов', 'text': 'Вставте в это поле номера вэйбилов PDF файлы которых необходимо найти.', 'textarea_title': 'Вставте в это поле номера вэйбилов PDF файлы которых необходимо ' 'найти.', 'submit_title': 'Начать поиск', 'element_id': 'find_button', 'element_method': 'click', 'spinner_message': 'Ожидайте окончания поиска...', }, RequestContext(request)) -- 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]<mailto:[email protected]>. To post to this group, send email to [email protected]<mailto:[email protected]>. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e833541c-0b75-486c-a06e-5aa8ccb5d446%40googlegroups.com<https://groups.google.com/d/msgid/django-users/e833541c-0b75-486c-a06e-5aa8ccb5d446%40googlegroups.com?utm_medium=email&utm_source=footer>. For more options, visit https://groups.google.com/d/optout. -- 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 post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/238cb955a51b4535990ba1259270e7c3%40ISS1.ISS.LOCAL. For more options, visit https://groups.google.com/d/optout.

