Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 140 for datetime (0.17 sec)

  1. tests/test_datetime_custom_encoder.py

    from datetime import datetime, timezone
    
    from fastapi import FastAPI
    from fastapi.testclient import TestClient
    from pydantic import BaseModel
    
    from .utils import needs_pydanticv1, needs_pydanticv2
    
    
    @needs_pydanticv2
    def test_pydanticv2():
        from pydantic import field_serializer
    
        class ModelWithDatetimeField(BaseModel):
            dt_field: datetime
    
            @field_serializer("dt_field")
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Jul 07 17:12:13 GMT 2023
    - 1.6K bytes
    - Viewed (0)
  2. tests/test_serialize_response_dataclass.py

            {
                "name": "baz",
                "date": datetime(2021, 7, 26),
                "price": 2.0,
                "owner_ids": [1, 2, 3],
            },
        ]
    
    
    @app.get("/items/objectlist", response_model=List[Item])
    def get_objectlist():
        return [
            Item(name="foo", date=datetime(2021, 7, 26)),
            Item(name="bar", date=datetime(2021, 7, 26), price=1.0),
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Aug 26 13:56:47 GMT 2022
    - 4.9K bytes
    - Viewed (0)
  3. docs_src/python_types/tutorial011.py

    from datetime import datetime
    from typing import List, Union
    
    from pydantic import BaseModel
    
    
    class User(BaseModel):
        id: int
        name: str = "John Doe"
        signup_ts: Union[datetime, None] = None
        friends: List[int] = []
    
    
    external_data = {
        "id": "123",
        "signup_ts": "2017-06-01 12:22",
        "friends": [1, "2", b"3"],
    }
    user = User(**external_data)
    print(user)
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Sep 02 15:56:35 GMT 2023
    - 498 bytes
    - Viewed (0)
  4. docs_src/extra_data_types/tutorial001.py

    from datetime import datetime, time, timedelta
    from typing import Union
    from uuid import UUID
    
    from fastapi import Body, FastAPI
    
    app = FastAPI()
    
    
    @app.put("/items/{item_id}")
    async def read_items(
        item_id: UUID,
        start_datetime: datetime = Body(),
        end_datetime: datetime = Body(),
        process_after: timedelta = Body(),
        repeat_at: Union[time, None] = Body(default=None),
    ):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Apr 19 00:11:40 GMT 2024
    - 755 bytes
    - Viewed (0)
  5. tests/test_tutorial/test_extra_data_types/test_tutorial001.py

                        "properties": {
                            "start_datetime": {
                                "title": "Start Datetime",
                                "type": "string",
                                "format": "date-time",
                            },
                            "end_datetime": {
                                "title": "End Datetime",
                                "type": "string",
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Apr 19 00:11:40 GMT 2024
    - 6.8K bytes
    - Viewed (0)
  6. docs_src/extra_data_types/tutorial001_py310.py

    from datetime import datetime, time, timedelta
    from uuid import UUID
    
    from fastapi import Body, FastAPI
    
    app = FastAPI()
    
    
    @app.put("/items/{item_id}")
    async def read_items(
        item_id: UUID,
        start_datetime: datetime = Body(),
        end_datetime: datetime = Body(),
        process_after: timedelta = Body(),
        repeat_at: time | None = Body(default=None),
    ):
        start_process = start_datetime + process_after
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Apr 19 00:11:40 GMT 2024
    - 724 bytes
    - Viewed (0)
  7. docs_src/python_types/tutorial011_py310.py

    from datetime import datetime
    
    from pydantic import BaseModel
    
    
    class User(BaseModel):
        id: int
        name: str = "John Doe"
        signup_ts: datetime | None = None
        friends: list[int] = []
    
    
    external_data = {
        "id": "123",
        "signup_ts": "2017-06-01 12:22",
        "friends": [1, "2", b"3"],
    }
    user = User(**external_data)
    print(user)
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Sat Sep 02 15:56:35 GMT 2023
    - 461 bytes
    - Viewed (0)
  8. docs_src/extra_data_types/tutorial001_an_py310.py

    from datetime import datetime, time, timedelta
    from typing import Annotated
    from uuid import UUID
    
    from fastapi import Body, FastAPI
    
    app = FastAPI()
    
    
    @app.put("/items/{item_id}")
    async def read_items(
        item_id: UUID,
        start_datetime: Annotated[datetime, Body()],
        end_datetime: Annotated[datetime, Body()],
        process_after: Annotated[timedelta, Body()],
        repeat_at: Annotated[time | None, Body()] = None,
    ):
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Apr 19 00:11:40 GMT 2024
    - 788 bytes
    - Viewed (0)
  9. docs_src/extra_data_types/tutorial001_an.py

    from datetime import datetime, time, timedelta
    from typing import Union
    from uuid import UUID
    
    from fastapi import Body, FastAPI
    from typing_extensions import Annotated
    
    app = FastAPI()
    
    
    @app.put("/items/{item_id}")
    async def read_items(
        item_id: UUID,
        start_datetime: Annotated[datetime, Body()],
        end_datetime: Annotated[datetime, Body()],
        process_after: Annotated[timedelta, Body()],
    Python
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Apr 19 00:11:40 GMT 2024
    - 830 bytes
    - Viewed (0)
  10. docs/ja/docs/tutorial/extra-data-types.md

        * リクエストとレスポンスでは`str`として表現されます。
    * `datetime.datetime`:
        * Pythonの`datetime.datetime`です。
        * リクエストとレスポンスはISO 8601形式の`str`で表現されます: `2008-09-15T15:53:00+05:00`
    * `datetime.date`:
        * Pythonの`datetime.date`です。
        * リクエストとレスポンスはISO 8601形式の`str`で表現されます: `2008-09-15`
    * `datetime.time`:
        * Pythonの`datetime.time`.
        * リクエストとレスポンスはISO 8601形式の`str`で表現されます: `14:23:55.003`
    * `datetime.timedelta`:
        * Pythonの`datetime.timedelta`です。
    Plain Text
    - Registered: Sun Apr 28 07:19:10 GMT 2024
    - Last Modified: Fri Mar 22 01:42:11 GMT 2024
    - 3.2K bytes
    - Viewed (0)
Back to top