Home / Function/ Form() — fastapi Function Reference

Form() — fastapi Function Reference

Architecture documentation for the Form() function in param_functions.py from the fastapi codebase.

Entity Profile

Dependency Diagram

graph TD
  a04eddc5_a187_664a_d781_fb175fd636d5["Form()"]
  24a9a43e_697f_81ce_6a7c_28a423a6f93b["param_functions.py"]
  a04eddc5_a187_664a_d781_fb175fd636d5 -->|defined in| 24a9a43e_697f_81ce_6a7c_28a423a6f93b
  44839a66_b7bf_3153_69cf_705d55a9871b["__init__()"]
  44839a66_b7bf_3153_69cf_705d55a9871b -->|calls| a04eddc5_a187_664a_d781_fb175fd636d5
  0e2b21da_a895_fba5_b0c3_8d2dd223a34a["__init__()"]
  0e2b21da_a895_fba5_b0c3_8d2dd223a34a -->|calls| a04eddc5_a187_664a_d781_fb175fd636d5
  style a04eddc5_a187_664a_d781_fb175fd636d5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

fastapi/param_functions.py lines 1654–1966

def Form(  # noqa: N802
    default: Annotated[
        Any,
        Doc(
            """
            Default value if the parameter field is not set.
            """
        ),
    ] = Undefined,
    *,
    default_factory: Annotated[
        Union[Callable[[], Any], None],
        Doc(
            """
            A callable to generate the default value.

            This doesn't affect `Path` parameters as the value is always required.
            The parameter is available only for compatibility.
            """
        ),
    ] = _Unset,
    media_type: Annotated[
        str,
        Doc(
            """
            The media type of this parameter field. Changing it would affect the
            generated OpenAPI, but currently it doesn't affect the parsing of the data.
            """
        ),
    ] = "application/x-www-form-urlencoded",
    alias: Annotated[
        Optional[str],
        Doc(
            """
            An alternative name for the parameter field.

            This will be used to extract the data and for the generated OpenAPI.
            It is particularly useful when you can't use the name you want because it
            is a Python reserved keyword or similar.
            """
        ),
    ] = None,
    alias_priority: Annotated[
        Union[int, None],
        Doc(
            """
            Priority of the alias. This affects whether an alias generator is used.
            """
        ),
    ] = _Unset,
    validation_alias: Annotated[
        Union[str, AliasPath, AliasChoices, None],
        Doc(
            """
            'Whitelist' validation step. The parameter field will be the single one
            allowed by the alias or set of aliases defined.
            """
        ),
    ] = None,
    serialization_alias: Annotated[
        Union[str, None],
        Doc(
            """
            'Blacklist' validation step. The vanilla parameter field will be the
            single one of the alias' or set of aliases' fields and all the other
            fields will be ignored at serialization time.
            """
        ),
    ] = None,
    title: Annotated[
        Optional[str],
        Doc(
            """
            Human-readable title.
            """
        ),
    ] = None,
    description: Annotated[
        Optional[str],
        Doc(
            """

Domain

Subdomains

Frequently Asked Questions

What does Form() do?
Form() is a function in the fastapi codebase, defined in fastapi/param_functions.py.
Where is Form() defined?
Form() is defined in fastapi/param_functions.py at line 1654.
What calls Form()?
Form() is called by 2 function(s): __init__, __init__.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free