Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sivabalan2088 opened this issue Apr 16, 2020 · 0 comments
Open

Comments

@sivabalan2088
Copy link

sivabalan2088 commented Apr 16, 2020

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()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant