]> git.ipfire.org Git - thirdparty/fastapi/sqlmodel.git/commitdiff
📝 Update admonitions, simplify and use defaults (#1915)
authorSebastián Ramírez <tiangolo@gmail.com>
Mon, 18 May 2026 11:41:36 +0000 (13:41 +0200)
committerGitHub <noreply@github.com>
Mon, 18 May 2026 11:41:36 +0000 (13:41 +0200)
27 files changed:
docs/advanced/decimal.md
docs/advanced/uuid.md
docs/databases.md
docs/db-to-code.md
docs/help.md
docs/tutorial/connect/create-connected-rows.md
docs/tutorial/connect/create-connected-tables.md
docs/tutorial/connect/read-connected-data.md
docs/tutorial/create-db-and-table.md
docs/tutorial/fastapi/limit-and-offset.md
docs/tutorial/fastapi/read-one.md
docs/tutorial/fastapi/response-model.md
docs/tutorial/fastapi/simple-hero-api.md
docs/tutorial/fastapi/tests.md
docs/tutorial/indexes.md
docs/tutorial/insert.md
docs/tutorial/many-to-many/index.md
docs/tutorial/many-to-many/link-with-extra-fields.md
docs/tutorial/relationship-attributes/cascade-delete-relationships.md
docs/tutorial/relationship-attributes/index.md
docs/tutorial/relationship-attributes/type-annotation-strings.md
docs/tutorial/select.md
docs/tutorial/update.md
docs/virtual-environments.md
docs_src/tutorial/automatic_id_none_refresh/annotations/en/tutorial002.md
docs_src/tutorial/fastapi/app_testing/tutorial001_py310/annotations/en/test_main_004.md
mkdocs.yml

index ce971b201b59ae88a85cfb15da349c2c0d663ac0..4439cba8bc46b79fe1b4f5d78e87ae384f3390cd 100644 (file)
@@ -23,7 +23,7 @@ Pydantic has special support for <a href="https://docs.pydantic.dev/latest/api/s
 
 When you use `Decimal` you can specify the number of digits and decimal places to support in the `Field()` function. They will be validated by Pydantic (for example when using FastAPI) and the same information will also be used for the database columns.
 
-/// info
+/// note
 
 For the database, **SQLModel** will use <a href="https://docs.sqlalchemy.org/en/20/core/type_basics.html#sqlalchemy.types.DECIMAL" class="external-link" target="_blank">SQLAlchemy's `DECIMAL` type</a>.
 
index abfcfeda2b07811c43d4c95553d11d8102c6ad77..c186390271fecc1841b3755a65eefbe0560f9433 100644 (file)
@@ -12,7 +12,7 @@ You might have seen **UUIDs**, for example in URLs. They look something like thi
 
 UUIDs can be particularly useful as an alternative to auto-incrementing integers for **primary keys**.
 
-/// info
+/// note
 
 Official support for UUIDs was added in SQLModel version `0.0.20`.
 
index de25ebb4cbf51e3695b866ca01f34b245db9c4f1..8c29b7f962954918c4304d09d9573e465e78fea1 100644 (file)
@@ -1,6 +1,6 @@
 # Intro to Databases
 
-/// info
+/// note
 
 Are you a seasoned developer and already know everything about databases? 🤓
 
@@ -317,7 +317,7 @@ Next, it receives the data and puts it in Python objects that you can continue t
 
 I'll tell you more about SQL, SQLModel, how to use them, and how they are related in the next sections.
 
-/// info  | Technical Details
+/// note  | Technical Details
 
 SQLModel is built on top of SQLAlchemy. It is, in fact, just <a href="https://www.sqlalchemy.org/" class="external-link" target="_blank">SQLAlchemy</a> and <a href="https://pydantic-docs.helpmanual.io/" class="external-link" target="_blank">Pydantic</a> mixed together with some sugar on top.
 
index fbba54c1629f200b4f1c7732a8164516454b23db..0bcb17f2909b400f0f58f93745f6b86ed3683194 100644 (file)
@@ -190,7 +190,7 @@ Then your code will continue to execute and calmly tell the user that it couldn'
 
 But we never deleted the `hero` table. 🎉
 
-/// info
+/// note
 
 Of course, there are also other ways to do SQL data sanitization without using a tool like **SQLModel**, but it's still a nice feature you get by default.
 
@@ -296,7 +296,7 @@ There are many ORMs available apart from **SQLModel**, you can read more about s
 
 ## SQL Table Names
 
-/// info  | Technical Background
+/// note  | Technical Background
 
 This is a bit of boring background for SQL purists. Feel free to skip this section. 😉
 
index a0cfa4ea0714735c482b60b6c0ac903d39aafce9..4065f679c169924a51199ffb09964df728b5cf61 100644 (file)
@@ -157,7 +157,7 @@ And if there's any other style or consistency need, I'll ask directly for that,
 
 * Then **comment** saying that you did that, that's how I will know you really checked it.
 
-/// info
+/// note
 
 Unfortunately, I can't simply trust PRs that just have several approvals.
 
index 2f952bf706b5d4cbe6b77afabe3515d5253331a2..230921054f9a49851460d4e0837c4539111ac6e4 100644 (file)
@@ -37,7 +37,7 @@ Each row in the table `hero` will point to a row in the table `team`:
 
 <img alt="table relationships" src="/img/tutorial/relationships/select/relationships2.drawio.svg">
 
-/// info
+/// note
 
 We will later update **Spider-Boy** to add him to the **Preventers** team too, but not yet.
 
index 2b1a4f875818c6aa4a7daeb19a3a6f11115301ed..14fc3c92550f48b50add6a0837a8f9beb372c4ff 100644 (file)
@@ -100,7 +100,7 @@ This is the name of the **table** in the database, so it is `"team"`, not the na
 
 If you had a custom table name, you would use that custom table name.
 
-/// info
+/// note
 
 You can learn about setting a custom table name for a model in the Advanced User Guide.
 
index 2868c69dd548151aa0df15822382ec8d003ecff0..5fa6fbf8c4074db65dcf08da7cd2e69763179621 100644 (file)
@@ -55,7 +55,7 @@ FROM hero, team
 WHERE hero.team_id = team.id
 ```
 
-/// info
+/// note
 
 Because we have two columns called `name`, one for `hero` and one for `team`, we can specify them with the prefix of the table name and the dot to make it explicit what we refer to.
 
@@ -133,7 +133,7 @@ For each iteration in the `for` loop we get a tuple with an instance of the clas
 
 And in this `for` loop we assign them to the variable `hero` and the variable `team`.
 
-/// info
+/// note
 
 There was a lot of research, design, and work behind **SQLModel** to make this provide the best possible developer experience.
 
index bbd5532bae9fe346e5ba7f93421c25607b40b202..aca59af46b2dbfb8d46282df8962cd29829ad8aa 100644 (file)
@@ -47,7 +47,7 @@ This class `Hero` **represents the table** for our heroes. And each instance we
 
 We use the config `table=True` to tell **SQLModel** that this is a **table model**, it represents a table.
 
-/// info
+/// note
 
 It's also possible to have models without `table=True`, those would be only **data models**, without a table in the database, they would not be **table models**.
 
@@ -366,7 +366,7 @@ INFO Engine COMMIT
 
 </div>
 
-/// info
+/// note
 
 I simplified the output above a bit to make it easier to read.
 
@@ -538,7 +538,7 @@ if __name__ == "__main__":
 
 ...will **not** be executed.
 
-/// info
+/// note
 
 For more information, check <a href="https://docs.python.org/3/library/__main__.html" class="external-link" target="_blank">the official Python docs</a>.
 
index 1a464a664f2b5b713ac9c169ff0c6a0a9a28ae41..12416fcc7e81dc9cfb4aa5ee107cee80201bf56a 100644 (file)
@@ -8,7 +8,7 @@ So, we probably want to limit it.
 
 Let's use the same **offset** and **limit** we learned about in the previous tutorial chapters for the API.
 
-/// info
+/// note
 
 In many cases, this is also called **pagination**.
 
@@ -32,7 +32,7 @@ So, to prevent it, we add additional validation to the `limit` query parameter,
 
 This way, a client can decide to take fewer heroes if they want, but not more.
 
-/// info
+/// note
 
 If you need to refresh how query parameters and their validation work, check out the docs in FastAPI:
 
index 03a65a0a2dad7bc4f5055c9d498aa4b40f1b5a46..593818dbae9c799051ed944c8b4bca03e718dd26 100644 (file)
@@ -8,7 +8,7 @@ Let's add a new *path operation* to read one single hero.
 
 We want to get the hero based on the `id`, so we will use a **path parameter** `hero_id`.
 
-/// info
+/// note
 
 If you need to refresh how *path parameters* work, including their data validation, check the <a href="https://fastapi.tiangolo.com/tutorial/path-params/" class="external-link" target="_blank">FastAPI docs about Path Parameters</a>.
 
index f9214332c6f56ef39071804fc73d1a07b5ecf1d7..a9f7f0f831f43d5c3a88f30e9192eb683e2ba6f0 100644 (file)
@@ -68,7 +68,7 @@ Additionally, because the schemas are defined in using a standard, there are man
 
 For example, client generators, that can automatically create the code necessary to talk to your API in many languages.
 
-/// info
+/// note
 
 If you are curious about the standards, FastAPI generates OpenAPI, that internally uses JSON Schema.
 
index 79cf075e1bfcd98a35e4b43c603f1ad6691f373d..f40fb1056fd342697e69401faf9131e388432893 100644 (file)
@@ -40,7 +40,7 @@ But here we will make sure we don't share the same **session** in more than one
 
 And we also need to disable it because in **FastAPI** each request could be handled by multiple interacting threads.
 
-/// info
+/// note
 
 That's enough information for now, you can read more about it in the <a href="https://fastapi.tiangolo.com/async/" class="external-link" target="_blank">FastAPI docs for `async` and `await`</a>.
 
@@ -68,7 +68,7 @@ This should be called only once at startup, not before every request, so we put
 
 ## Create Heroes *Path Operation*
 
-/// info
+/// note
 
 If you need a refresher on what a **Path Operation** is (an endpoint with a specific HTTP Operation) and how to work with it in FastAPI, check out the <a href="https://fastapi.tiangolo.com/tutorial/first-steps/" class="external-link" target="_blank">FastAPI First Steps docs</a>.
 
@@ -80,7 +80,7 @@ It will be called when a user sends a request with a `POST` **operation** to the
 
 {* ./docs_src/tutorial/fastapi/simple_hero_api/tutorial001_py310.py ln[23:37] hl[31:32] *}
 
-/// info
+/// note
 
 If you need a refresher on some of those concepts, checkout the FastAPI documentation:
 
@@ -152,7 +152,7 @@ $ fastapi dev main.py
 
 </div>
 
-/// info
+/// note
 
 The `fastapi` command uses <a href="https://www.uvicorn.org/" class="external-link" target="_blank">Uvicorn</a> underneath.
 
index f7fd92c9cb735e376ff2d16f77284134d5393f42..3ed6c50a8503924a3bb1bf0c5e0dcc1d93b675a8 100644 (file)
@@ -214,7 +214,7 @@ Do we really have to duplicate all that for **each test**? No, we can do better!
 
 We are using **pytest** to run the tests. And pytest also has a very similar concept to the **dependencies in FastAPI**.
 
-/// info
+/// note
 
 In fact, pytest was one of the things that inspired the design of the dependencies in FastAPI.
 
index 459ee8ce34f3da6a062c9d3132ca46306413e4d6..8579384697e565678bc8f30c53f7b02c69386800 100644 (file)
@@ -267,7 +267,7 @@ We use the same `Field()` again as we did before, and set `index=True`. That's i
 
 Notice that we didn't set an argument of `default=None` or anything similar. This means that **SQLModel** (thanks to Pydantic) will keep it as a **required** field.
 
-/// info
+/// note
 
 SQLModel (actually SQLAlchemy) will **automatically generate the index name** for you.
 
index e2d9a4637f16916b14dc0bb497637c9ea2eeac39..82a22290286115bfdf67f115bc1b0af4cb578fb9 100644 (file)
@@ -193,7 +193,7 @@ And once we are ready, we can **commit** those changes, and then the **session**
 
 This makes the interactions with the database more efficient (plus some extra benefits).
 
-/// info  | Technical Details
+/// note  | Technical Details
 
 The session will create a new transaction and execute all the SQL code in that transaction.
 
index 5cb3067e4ad4ef8ec9a26e21717c8017dd2adb1a..2e92df8718c9a4707ffb092f75215110f40b9e69 100644 (file)
@@ -109,7 +109,7 @@ Specifically, the new link table `heroteamlink` would be:
 </tr>
 </table>
 
-/// info
+/// note
 
 Other names used for this **link table** are:
 
index 7c7756bcd2ce913e0e92d5e22fc4bb8c99e75774..8e7d9de087e3d5c19faec13ec644fb4ce3d8392b 100644 (file)
@@ -39,7 +39,7 @@ The new **relationship attributes** have their own `back_populates` pointing to
 * `team`: has `back_populates="hero_links"`, because in the `Team` model, the attribute will contain the links to the **team's heroes**.
 * `hero`: has `back_populates="team_links"`, because in the `Hero` model, the attribute will contain the links to the **hero's teams**.
 
-/// info
+/// note
 
 In SQLAlchemy this is called an Association Object or Association Model.
 
index 3b6fe9156c868a6b1ddd7edcf0d48dd9f93a4a0c..ea1d4705185b5c8d99fbba2e6824875e7b575ae1 100644 (file)
@@ -8,7 +8,7 @@ Should their `team_id` instead be set to `NULL` in the database?
 
 Let's see how to configure that with **SQLModel**.
 
-/// info
+/// note
 
 This feature, including `cascade_delete`, `ondelete`, and `passive_deletes`, is available since SQLModel version `0.0.21`.
 
@@ -440,7 +440,7 @@ To be able to test this out with SQLite, we first need to enable foreign key sup
 
 {* ./docs_src/tutorial/relationship_attributes/cascade_delete_relationships/tutorial003_py310.py ln[30:33] hl[33] *}
 
-/// info
+/// note
 
 You can learn more about SQLite, foreign keys, and this SQL command on the <a href="https://docs.sqlalchemy.org/en/20/dialects/sqlite.html#foreign-key-support" class="external-link" target="_blank">SQLAlchemy docs</a>.
 
index f63b2669e3e32478dc3ffc4d27987e4c38aeb7d9..c45f75b4ee7d87dbe8ba145b686bbbe26a224643 100644 (file)
@@ -6,7 +6,7 @@ And then we read the data together with `select()` and using `.where()` or `.joi
 
 Now we will see how to use **Relationship Attributes**, an extra feature of **SQLModel** (and SQLAlchemy), to work with the data in the database in a much more familiar way, and closer to normal Python code.
 
-/// info
+/// note
 
 When I say "**relationship**" I mean the standard dictionary term, of data related to other data.
 
index 74b97f08d12af83690d07ce0ad5969ac4bab59e6..ca81141683da3d2a20e0c9f6a9ab50fe203d8e71 100644 (file)
@@ -16,7 +16,7 @@ And of course, **SQLModel** can also understand it in the string correctly. ✨
 
 That is actually part of Python, it's the current official solution to handle it.
 
-/// info
+/// note
 
 There's a lot of work going on in Python itself to make that simpler and more intuitive, and find ways to make it possible to not wrap the class in a string.
 
index f31722d445fe7160f1593d630478f0e932cf7211..df0d1c0ff67aac6179cf6c8dc7d1b5fcaa409eee 100644 (file)
@@ -289,7 +289,7 @@ And the second section reading data from the database could be in another functi
 
 So, both sections could be in **different places** and would need their own sessions.
 
-/// info
+/// note
 
 To be fair, in this example all that code could actually share the same **session**, there's actually no need to have two here.
 
@@ -319,7 +319,7 @@ After printing it, we would see something like:
 ]
 ```
 
-/// info
+/// note
 
 It would actually look more compact, I'm formatting it a bit for you to see that it is actually a list with all the data.
 
@@ -353,7 +353,7 @@ SQLAchemy also has its own `select`, and SQLModel's `select` uses SQLAlchemy's `
 
 But SQLModel's version does a lot of **tricks** with type annotations to make sure you get the best **editor support** possible, no matter if you use **VS Code**, **PyCharm**, or something else. ✨
 
-/// info
+/// note
 
 There was a lot of work and research, with different versions of the internal code, to improve this as much as possible. 🤓
 
index 4066379218465b97224794686c30e665971c16c1..55af9c94dd19f55ba61c87f45911d5d60c36cd6e 100644 (file)
@@ -34,7 +34,7 @@ And the second part, with the `WHERE`, defines to which rows it should apply tha
 
 In this case, as we only have one hero with the name `"Spider-Boy"`, it will only apply the update in that row.
 
-/// info
+/// note
 
 Notice that in the `UPDATE` the single equals sign (`=`) means **assignment**, setting a column to some value.
 
index 131cd53d767ddd6111040da62ff307553bb44802..214c11213ec831fe91c3979bfd7e6869652a869f 100644 (file)
@@ -2,7 +2,7 @@
 
 When you work in Python projects you probably should use a **virtual environment** (or a similar mechanism) to isolate the packages you install for each project.
 
-/// info
+/// note
 
 If you already know about virtual environments, how to create them and use them, you might want to skip this section. 🤓
 
@@ -18,7 +18,7 @@ A **virtual environment** is a directory with some files in it.
 
 ///
 
-/// info
+/// note
 
 This page will teach you how to use **virtual environments** and how they work.
 
index fee38368dc2b6a4a046f069c92c1eb85b1e08d3f..eea540309b33f92cd9116209f84d37f124549990 100644 (file)
 
 33. Print the `hero_1`.
 
-    /// info
+    /// note
 
     Even if the `hero_1` wasn't fresh, this would **not** trigger a `refresh` making the **session** use the **engine** to fetch data from the database because it is not accessing an attribute.
 
 
 34. Print the `hero_2`.
 
-    /// info
+    /// note
 
     Even if the `hero_2` wasn't fresh, this would **not** trigger a `refresh` making the **session** use the **engine** to fetch data from the database because it is not accessing an attribute.
 
 
 35. Print the `hero_3`.
 
-    /// info
+    /// note
 
     Even if the `hero_3` wasn't fresh, this would **not** trigger a `refresh` making the **session** use the **engine** to fetch data from the database because it is not accessing an attribute.
 
index de754c5e763a18ed1fa71cf0f4b9008aec34064f..3be0f1f7c159c9d2913c1cf8caef167a5834a2dd 100644 (file)
@@ -22,7 +22,7 @@
 
     We tell it that with the `poolclass=StaticPool` parameter.
 
-    /// info
+    /// note
 
     You can read more details in the <a href="https://docs.sqlalchemy.org/en/14/dialects/sqlite.html#using-a-memory-database-in-multiple-threads" class="external-link" target="_blank">SQLAlchemy documentation about Using a Memory Database in Multiple Threads</a>
 
index 191e06b0e47053901ea6a92bf2606a9158bd3a9d..8db44a1245af0410f0146a591f5e19da2ec2b942 100644 (file)
@@ -165,17 +165,6 @@ markdown_extensions:
 
   # pymdownx blocks
   pymdownx.blocks.admonition:
-    types:
-    - note
-    - attention
-    - caution
-    - danger
-    - error
-    - tip
-    - hint
-    - warning
-    # Custom types
-    - info
   pymdownx.blocks.details:
   pymdownx.blocks.tab:
     alternate_style: True