Skip to content

Better error message when view return type is not supported #3214

Description

@davidism

One of the most common errors/questions on Stack Overflow is some variant of "what does 'dict object is not callable' mean, how do I return JSON?" Now that #3111 is merged, returning dict from a view produces a JSON response. However, there are still plenty of other types that will produce that error, such as returning a bool, or a User object, or a list of rows from a database query.

Flask.make_response should check whether an otherwise unhandled value is a BaseResponse subclass or a callable before treating it as such. Then it can raise a more helpful error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    save-for-sprintPlease don't pick this unless you're participating in an official sprint.

    Type

    No type

    Fields

    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