Why my custom script processing data just fine on local development Django server but not on Digital Ocean App?

Does anyone know why when I upload a CSV file locally to the Django development server, my code does work as plan as in processing the CSV file and adding data to the database correctly, but when I try the same thing with the production server on Digital Ocean using App service - the CSV file just uploaded without having getting processed? I notice this because no new product is being added when uploading the CSV file to the production server on Digital Ocean. By the way, the local development server is also using S3 storage - so the same file got uploaded to Amazon S3 all the same - but the code processes the file in the development server but not on the production server - the development server is on my laptop. The production server is on Digital Ocean's App. I did something like this in the code:

from django.core.files.storage import default_storage

def upload_csvs(request):
    current_page_bread_crumb_title = 'upload csv'
    form = CsvsModelForm(request.POST or None, request.FILES or None)
    random_category = None
    if form.is_valid():
        form.save()
        # reset form after save
        form = CsvsModelForm()
        # Only getting csv file that isn't activated or being used already.
        get_csv_data = Csvs.objects.filter(activated=False).order_by('-id').first()
        with default_storage.open(get_csv_data.file_name.name, mode='r') as f:
            reader = csv.reader(f)
            for i, row in enumerate(reader):
                if i == 0:
                    pass
                else:
              random_category = choice([3, 4, 5, 6, 7, 8, 9, 10])

                    try:
                        Product.objects.create(product_name=row[0],
                                               slug=row[0].lower().replace(' ', '-'),
                                               product_description=row[1],
                                               product_additional_description=row[2],
                                               product_detail_banner_text=row[3],
                                               product_zoom_content_1=row[4],
                                               product_zoom_content_2=row[5],
                                               product_zoom_content_3=row[6],
                                               price=Decimal(row[7]),
                                 stock=row[27],
                                               is_available=row[28],
                                               category=Category.objects.get(id=random_category),
                                               homepage_display=row[30],
                                               )
                    except ObjectDoesNotExist:
                        pass
        get_csv_data.activated = True
        get_csv_data.save()

    context = {
        'form': form,
        'current_page_bread_crumb_title': current_page_bread_crumb_title,
    }
    return render(request, 'csvs.html', context)
Back to Top