In PynamoDB, when running a DynamoDB query, the first two positional arguments are the hash key (primary key) and filters for the range key (sort key). To do a filter expression without querying on the range key, explicitly provide the filter_condition_expression parameter.

Example#

    return [
        post
        for post in PostModel.query(
            user_id,
            filter_condition=(PostModel.media_type == "IMAGE") & PostModel.image_key.exists(),
            limit=100,
        )
    ]
    ```