Invalid Django form after . read()

Asked

Viewed 14 times

0

My code is like this

Em Views:

def cadastrar(request):
    if request.method == 'POST':
        arquivo = request.FILES["imagem"]
        leitura = arquivo.read()
            if form.is_valid():
                form.save()

The form is saved only if the command leitura = arquivo.read() be commented #.

If it is not commented, after the execution of that line, the form is invalid.

Does anyone know why this is happening?

I’m using Django 3.2.3

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.