Skip to content

how to delete from filelist = ListField(FileField()) #1835

Description

@francisliyy

I have a listField for storing file list, for example, filelist = ListField(FileField())
how can I delete one file from this list? I try to get one file then use file.delete(), it really deletes the file from fs.files, but from filelist, you can still have two object id inside, like
"filelist" : [
ObjectId("5b6b45ab360e2eceefa39f18"),
ObjectId("5b6b5735360e2ed0cad8e9f7")
],

But if I try to use pull like
Classname.objects(id=pk).update_one(pull__filelist=file), it throws error "bson.errors.InvalidDocument: Cannot encode object: <GridFSProxy: 5b6b5735360e2ed0cad8e9f7>"

How can I deal with that? Please help, thank you.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions