Csv file is not generating after I deployed ti pythonanywhere

I have my view which is generating csv file, but it doesn't work after I deployed my project to python anywhere

Error: enter image description here

view: `def generate_csv(request, pk): if request.method == 'POST': columns = models.Column.objects.all().filter(schema__id=pk)

    names = [None for _ in columns]
    types = [None for _ in columns]
    for column in columns:
        names[int(column.order) - 1] = column.name
        types[int(column.order) - 1] = column.type

    form = forms.DataSetForm(request.POST)
    fake = Faker()

    if form.is_valid():
        rows = int(form['rows'].value())
        schema = models.Schema.objects.get(id=pk)
        file_name = f'{schema.title}{fake.pyint()}.csv'
        file = open(f'media/{file_name}', mode='w', newline='')
        dataset = models.DataSet(schema=schema, csv_file=f'{file_name}')

        file_writer = csv.writer(file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)

        for _ in range(rows):
            data = []
            for i in types:


        dataset.status = True
        return JsonResponse({}, status=200)
        return JsonResponse({'error': form.errors}, status=400)

return JsonResponse({'error': ''}, status=400)`

I think the problem is that I have to create the csv file in a different way, but I don't know how, can you help me?

Back to Top