Skip to content

Not able to upload large excel or CSV file with the size 10Mb #61

@sivabalan2088

Description

@sivabalan2088

Trying to import 10Mb CSV file but getting no response.
But able to import with 500 records

About CSV file
Total no of records= 157797
No of columns = 8

Updated the settings.py as below

FILE_UPLOAD_MAX_MEMORY_SIZE = 15728640
DATA_UPLOAD_MAX_MEMORY_SIZE = 15728640

And the view defined as

class ImportParts(APIView):

   def post(self, request):
    if request.method == "POST":
        form = UploadFileForm(request.POST,
                              request.FILES)

        def choice_func(row):
            q = Parts.objects.filter(cno=row[1], sNo=row[2])
            if q:
                dictionary = dict(zip(model_dict, row))
                q.update(**dictionary)
                row = []
            return row
        if form.is_valid():
            request.FILES['file'].save_to_database(
                model=Parts,
                initializer=choice_func,
                mapdict=(
                    model_dict
                )
            )
            return JsonResponse({"success": True}, status=status.HTTP_201_CREATED)
        else:
            return HttpResponseBadRequest()
    return HttpResponseBadRequest()`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions