Home > Back-end >  Error TypeError: 'method' object is not subscriptable in Flask
Error TypeError: 'method' object is not subscriptable in Flask

Time:01-04

Very good day!

So, what i need to do, if i have an error TypeError: 'method' object is not subscriptable in Flas

file = flask.request.files.getlist['propert_photo[]']
TypeError: 'method' object is not subscriptable

    <div >
        <label for="exampleFormControlFile1">Фотографии</label>
        <input name = "propert_photo[]" type="file" accept="image/png" multiple=""  id="exampleFormControlFile1">
    </div>

pls help

CodePudding user response:

file = flask.request.files.getlist['propert_photo[]']
should be
file = flask.request.files.getlist('propert_photo[]')

getlist is a method, and a method call uses () and not [].

"Subscriptable" in Python refers to whether or not you can use the square bracket syntax (like a[0]) on an object (or, in other words: whether or not it implements the __getitem__() method). Indeed, a method/function object does not enable this syntax.

  •  Tags:  
  • Related