Skip to content

Commit 4f9b2ea

Browse files
authored
📝 Update includes for docs/advanced/uuid.md (#1151)
1 parent 06de217 commit 4f9b2ea

File tree

1 file changed

+4
-168
lines changed

1 file changed

+4
-168
lines changed

docs/advanced/uuid.md

Lines changed: 4 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -80,45 +80,7 @@ We don't call `uuid.uuid4()` ourselves in the code (we don't put the parenthesis
8080

8181
This means that the UUID will be generated in the Python code, **before sending the data to the database**.
8282

83-
//// tab | Python 3.10+
84-
85-
```Python hl_lines="1 7"
86-
{!./docs_src/advanced/uuid/tutorial001_py310.py[ln:1-10]!}
87-
88-
# Code below omitted 👇
89-
```
90-
91-
////
92-
93-
//// tab | Python 3.7+
94-
95-
```Python hl_lines="1 8"
96-
{!./docs_src/advanced/uuid/tutorial001.py[ln:1-11]!}
97-
98-
# Code below omitted 👇
99-
```
100-
101-
////
102-
103-
/// details | 👀 Full file preview
104-
105-
//// tab | Python 3.10+
106-
107-
```Python
108-
{!./docs_src/advanced/uuid/tutorial001_py310.py!}
109-
```
110-
111-
////
112-
113-
//// tab | Python 3.7+
114-
115-
```Python
116-
{!./docs_src/advanced/uuid/tutorial001.py!}
117-
```
118-
119-
////
120-
121-
///
83+
{* ./docs_src/advanced/uuid/tutorial001_py310.py ln[1:10] hl[1,7] *}
12284

12385
Pydantic has support for <a href="https://docs.pydantic.dev/latest/api/standard_library_types/#uuid" class="external-link" target="_blank">`UUID` types</a>.
12486

@@ -132,99 +94,15 @@ As `uuid.uuid4` will be called when creating the model instance, even before sen
13294

13395
And that **same ID (a UUID)** will be saved in the database.
13496

135-
//// tab | Python 3.10+
136-
137-
```Python hl_lines="5 7 9 14"
138-
# Code above omitted 👆
139-
140-
{!./docs_src/advanced/uuid/tutorial001_py310.py[ln:23-34]!}
141-
142-
# Code below omitted 👇
143-
```
144-
145-
////
146-
147-
//// tab | Python 3.7+
148-
149-
```Python hl_lines="5 7 9 14"
150-
# Code above omitted 👆
151-
152-
{!./docs_src/advanced/uuid/tutorial001.py[ln:24-35]!}
153-
154-
# Code below omitted 👇
155-
```
156-
157-
////
158-
159-
/// details | 👀 Full file preview
160-
161-
//// tab | Python 3.10+
162-
163-
```Python
164-
{!./docs_src/advanced/uuid/tutorial001_py310.py!}
165-
```
166-
167-
////
168-
169-
//// tab | Python 3.7+
170-
171-
```Python
172-
{!./docs_src/advanced/uuid/tutorial001.py!}
173-
```
174-
175-
////
176-
177-
///
97+
{* ./docs_src/advanced/uuid/tutorial001_py310.py ln[23:34] hl[25,27,29,34] *}
17898

17999
### Select a Hero
180100

181101
We can do the same operations we could do with other fields.
182102

183103
For example we can **select a hero by ID**:
184104

185-
//// tab | Python 3.10+
186-
187-
```Python hl_lines="15"
188-
# Code above omitted 👆
189-
190-
{!./docs_src/advanced/uuid/tutorial001_py310.py[ln:37-54]!}
191-
192-
# Code below omitted 👇
193-
```
194-
195-
////
196-
197-
//// tab | Python 3.7+
198-
199-
```Python hl_lines="15"
200-
# Code above omitted 👆
201-
202-
{!./docs_src/advanced/uuid/tutorial001.py[ln:38-55]!}
203-
204-
# Code below omitted 👇
205-
```
206-
207-
////
208-
209-
/// details | 👀 Full file preview
210-
211-
//// tab | Python 3.10+
212-
213-
```Python
214-
{!./docs_src/advanced/uuid/tutorial001_py310.py!}
215-
```
216-
217-
////
218-
219-
//// tab | Python 3.7+
220-
221-
```Python
222-
{!./docs_src/advanced/uuid/tutorial001.py!}
223-
```
224-
225-
////
226-
227-
///
105+
{* ./docs_src/advanced/uuid/tutorial001_py310.py ln[37:54] hl[49] *}
228106

229107
/// tip
230108

@@ -238,49 +116,7 @@ SQLModel (actually SQLAlchemy) will take care of making it work. ✨
238116

239117
We could also select by ID with `session.get()`:
240118

241-
//// tab | Python 3.10+
242-
243-
```Python hl_lines="15"
244-
# Code above omitted 👆
245-
246-
{!./docs_src/advanced/uuid/tutorial002_py310.py[ln:37-54]!}
247-
248-
# Code below omitted 👇
249-
```
250-
251-
////
252-
253-
//// tab | Python 3.7+
254-
255-
```Python hl_lines="15"
256-
# Code above omitted 👆
257-
258-
{!./docs_src/advanced/uuid/tutorial002.py[ln:38-55]!}
259-
260-
# Code below omitted 👇
261-
```
262-
263-
////
264-
265-
/// details | 👀 Full file preview
266-
267-
//// tab | Python 3.10+
268-
269-
```Python
270-
{!./docs_src/advanced/uuid/tutorial002_py310.py!}
271-
```
272-
273-
////
274-
275-
//// tab | Python 3.7+
276-
277-
```Python
278-
{!./docs_src/advanced/uuid/tutorial002.py!}
279-
```
280-
281-
////
282-
283-
///
119+
{* ./docs_src/advanced/uuid/tutorial002_py310.py ln[37:53] hl[49] *}
284120

285121
The same way as with other fields, we could update, delete, etc. 🚀
286122

0 commit comments

Comments
 (0)