#django
Вопрос:
У меня есть это в моем admin.py
:
# function to upload the data
def upload_data(self, request):
# if the request from the form is a post method
if request.method == 'POST':
# get the file
data_file = request.FILES["data_upload"]
# get current active tab
active_sheet = load_workbook(data_file).active
try:
# only save if not the first field. first field is reserved for the labels
for row in range(2,active_sheet.max_row 1):
# save the new user into the user model
new_user = get_user_model().objects.update_or_create(
username = active_sheet["{}{}".format("A", row)].value,
email = active_sheet["{}{}".format("B", row)].value,
)
# return to admin/url
url = reverse('admin:index') 'url'
return HttpResponseRedirect(url)
except Exception as e:
logger.error(e)
form = DataImportForm()
data = {"form": form}
return render(request, 'admin/custom_bulk_upload.html', data)
которая представляет собой простую форму для массовой загрузки данных. Это хорошо на моем локальном хосте, но сервер возвращает a 502 Bad Gateway Reply
.
В журнале ошибок nginx я вижу следующее:
upstream prematurely closed connection while reading response header from upstream
Я понимаю, что это из-за очень больших данных, которые пытаются загрузить из файла Excel. Как я могу решить эту проблему?