Skip to content

Commit

Permalink
docs: fix highlight of code example in "Providing values for nested d…
Browse files Browse the repository at this point in the history
…ata" (#3815)

Co-authored-by: Janek Nouvertné <[email protected]>
  • Loading branch information
sobolevn and provinzkraut authored Oct 17, 2024
1 parent 45d5ec1 commit f534f52
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/usage/dto/1-abstract-dto.rst
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ nested model with excluded fields.

.. literalinclude:: /examples/data_transfer_objects/factory/providing_values_for_nested_data.py
:language: python
:emphasize-lines: 10,11,12,13,21,29,35
:emphasize-lines: 9-12,20,28,34
:linenos:

The double-underscore syntax ``address__id`` passed as a keyword argument to the
Expand All @@ -239,7 +239,7 @@ nested attribute. In this case, it's used to provide a value for the ``id`` attr
within the ``Person`` instance.

This is a common convention in Python for dealing with nested structures. The double underscore can be interpreted as
"traverse through", so ``address__id`` means "traverse through address to get to id".
"traverse through", so ``address__id`` means "traverse through address to get to its id".

In the context of this script, ``create_instance(id=1, address__id=2)`` is saying "create a new ``Person`` instance from
the client data given an id of ``1``, and supplement the client address data with an id of ``2``".
Expand Down

0 comments on commit f534f52

Please sign in to comment.