Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ answer newbie questions, and generally made Django that much better:
Slawek Mikula <slawek dot mikula at gmail dot com>
sloonz <simon.lipp@insa-lyon.fr>
smurf@smurf.noris.de
Somi Jeong <https://github.com/1wos>
sopel
Sreehari K V <sreeharivijayan619@gmail.com>
Sridhar Marella <sridhar562345@gmail.com>
Expand Down
12 changes: 12 additions & 0 deletions docs/ref/models/instances.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ need to :meth:`~Model.save`.

book = Book.objects.create_book("Pride and Prejudice")

.. admonition:: Setting attributes does not convert types

Setting a model attribute does not convert the value to the field's Python
type. That conversion happens when the model is :ref:`validated
<validating-objects>`. Although a field assigned a value of a different
type (for example, a string assigned to a
:class:`~django.db.models.UUIDField`) may be converted when
:meth:`~Model.save` executes a query, the in-memory instance will keep the
original value until it is :ref:`reloaded <refreshing-objects>`.

Customizing model loading
-------------------------

Expand Down Expand Up @@ -131,6 +141,8 @@ The example above shows a full ``from_db()`` implementation to clarify how that
is done. In this case it would be possible to use a ``super()`` call in the
``from_db()`` method.

.. _refreshing-objects:

Refreshing objects from database
================================

Expand Down
Loading