diff --git a/docs/en/docs/tutorial/request-form-models.md b/docs/en/docs/tutorial/request-form-models.md index 00ab1c341..7f1ddd57c 100644 --- a/docs/en/docs/tutorial/request-form-models.md +++ b/docs/en/docs/tutorial/request-form-models.md @@ -81,7 +81,7 @@ Say, for example, you were generating an HTML form from a model, and that model had a boolean field in it that you wanted to display as a checkbox with a default `True` value: -{* ../../docs_src/request_form_models/tutorial003_an_py39.py hl[10,18:22] *} +{* ../../docs_src/request_form_models/tutorial003_an_py39.py hl[11,10:23] *} This works as expected when the checkbox remains checked, the form encoded data in the request looks like this: @@ -130,7 +130,7 @@ Validation context is a pydantic v2 only feature! /// -{* ../../docs_src/request_form_models/tutorial004_an_py39.py hl[3,12:24] *} +{* ../../docs_src/request_form_models/tutorial004_an_py39.py hl[7,13:25] *} And with that, our form model should behave as expected when it is used with a form, JSON input, or elsewhere in the program! diff --git a/docs_src/request_form_models/tutorial003.py b/docs_src/request_form_models/tutorial003.py index 5c2b3dd31..b0cbd6ff3 100644 --- a/docs_src/request_form_models/tutorial003.py +++ b/docs_src/request_form_models/tutorial003.py @@ -1,12 +1,14 @@ -from pydantic import BaseModel from fastapi import FastAPI, Form, Request from fastapi.responses import HTMLResponse from fastapi.templating import Jinja2Templates from jinja2 import DictLoader, Environment +from pydantic import BaseModel + class MyModel(BaseModel): checkbox: bool = True + form_template = """