Skip to content

# Django Settings

Bases: `BaseModel`

Source code in `ninja/conf.py`

     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35

    class Settings(BaseModel):
        model_config = ConfigDict(from_attributes=True)
        # Pagination
        PAGINATION_CLASS: str = Field(
            "ninja.pagination.LimitOffsetPagination", alias="NINJA_PAGINATION_CLASS"
        )
        PAGINATION_DEFAULT_ORDERING: Tuple[str, ...] = Field(
            ("-pk",), alias="NINJA_PAGINATION_DEFAULT_ORDERING"
        )
        PAGINATION_MAX_OFFSET: int = Field(100, alias="NINJA_PAGINATION_MAX_OFFSET")
        PAGINATION_PER_PAGE: int = Field(100, alias="NINJA_PAGINATION_PER_PAGE")
        PAGINATION_MAX_PER_PAGE_SIZE: int = Field(100, alias="NINJA_MAX_PER_PAGE_SIZE")
        PAGINATION_MAX_LIMIT: int = Field(inf, alias="NINJA_PAGINATION_MAX_LIMIT")  # type: ignore

        # Throttling
        NUM_PROXIES: Optional[int] = Field(None, alias="NINJA_NUM_PROXIES")
        DEFAULT_THROTTLE_RATES: Dict[str, Optional[str]] = Field(
            {
                "auth": "10000/day",
                "user": "10000/day",
                "anon": "1000/day",
            },
            alias="NINJA_DEFAULT_THROTTLE_RATES",
        )

        FIX_REQUEST_FILES_METHODS: Set[str] = Field(
            {"PUT", "PATCH", "DELETE"}, alias="NINJA_FIX_REQUEST_FILES_METHODS"
        )