Django возвращает данные изображения как None

Мой utils.py:

import base64, uuid
from django.core.files.base import ContentFile

def get_report_image(data):
    f , str_image = data.split(';base64,')
    print(f)
    print(str_image)
    decoded_img = base64.b64decode(str_image)
    img_name = str(uuid.uuid4())[:10] + '.png'
    data = ContentFile(decoded_img, name=img_name)
    return data

Когда я пытаюсь получить отчет, я получаю ошибку сервера 500:

Internal Server Error: /reports/save/
Traceback (most recent call last):
  File "C:\Users\1\AppData\Local\Programs\Python\Python38\
go\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Users\1\AppData\Local\Programs\Python\Python38\
go\core\handlers\base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, *
  File "C:\Users\1\PycharmProjects\StasProject\sales_proje
line 13, in create_report_view
    img = get_report_image(image)
  File "C:\Users\1\PycharmProjects\StasProject\sales_proje
line 5, in get_report_image
    f , str_image = img.split(';base64,')
AttributeError: 'NoneType' object has no attribute 'split'

Хотя в консоли браузера я могу найти 23 kbs данных, которые идут как data:image/png;base64, и кучу символов. Я пытаюсь получить последние. Почему он не видит эти данные?

У меня views.py выглядит следующим образом:

from django.shortcuts import render
from profiles.models import Profile
from django.http import JsonResponse
from .utils import get_report_image
from .models import Report

def create_report_view(request):
    if request.is_ajax():
        name = request.POST.get('name')
        remarks = request.POST.get('remarks')
        image = request.POST.get('image')

        img = get_report_image(image)
        Report.object.create(name=name, remarks=remarks, image=img, author=author)

        author = Profile.objects.get(user=request.user)
        return JsonResponse({'msg': 'send'})
    return JsonResponse({})
Вернуться на верх