Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 2 additions & 70 deletions docs/tutorial/connect/update-data-connections.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,83 +37,15 @@ Now we'll see how to **update** those connections between rows tables.

We will continue with the code we used to create some heroes, and we'll update them.

/// details | 👀 Full file preview

//// tab | Python 3.10+

```Python
{!./docs_src/tutorial/connect/insert/tutorial001_py310.py!}
```

////

//// tab | Python 3.7+

```Python
{!./docs_src/tutorial/connect/insert/tutorial001.py!}
```

////

///
{* ./docs_src/tutorial/connect/insert/tutorial001_py310.py *}

## Assign a Team to a Hero

Let's say that **Tommy Sharp** uses his "rich uncle" charms to recruit **Spider-Boy** to join the team of the **Preventers**, now we need to update our Spider-Boy hero object to connect it to the Preventers team.

Doing it is just like updating any other field:

//// tab | Python 3.10+

```Python hl_lines="8"
# Code above omitted 👆

{!./docs_src/tutorial/connect/update/tutorial001_py310.py[ln:29-30]!}

# Previous code here omitted 👈

{!./docs_src/tutorial/connect/update/tutorial001_py310.py[ln:60-64]!}

# Code below omitted 👇
```

////

//// tab | Python 3.7+

```Python hl_lines="8"
# Code above omitted 👆

{!./docs_src/tutorial/connect/update/tutorial001.py[ln:31-32]!}

# Previous code here omitted 👈

{!./docs_src/tutorial/connect/update/tutorial001.py[ln:62-66]!}

# Code below omitted 👇
```

////

/// details | 👀 Full file preview

//// tab | Python 3.10+

```Python
{!./docs_src/tutorial/connect/update/tutorial001_py310.py!}
```

////

//// tab | Python 3.7+

```Python
{!./docs_src/tutorial/connect/update/tutorial001.py!}
```

////

///
{* ./docs_src/tutorial/connect/update/tutorial001_py310.py ln[29:30] hl[8] *}

We can simply **assign** a value to that field attribute `team_id`, then `add()` the hero to the session, and then `commit()`.

Expand Down
Loading