Possible bug, or possible docs error.
|Reported by:||Oroku Saki||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||Oroku Saki, Karen Tracey||Triage Stage:||Unreviewed|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I wanted to use this to return empty strings for password fields, and
$50.00 format for money that's stored as a decimal. You can imagine my surprise when I found out that I was trying to save
$50.00 to a decimal field, and
'' as somebody's password. The confusion arose from this:
In the following docs, it says that
get_prep_value() is the reverse of
to_python() (which would infer that
get_prep_value() is used to prepare incoming data, and
to_python() is used on outgoing data.
However, upon inspection of the code I found the following.
def get_prep_value(self, value): return self.to_python(value)
They are in fact not the reverse of each other, but in some cases one in the same, since one uses the other for implementation.
I'm starting this as a ORM ticket rather than a docs ticket, only because with the above mentioned there doesn't appear to be a possible way to have a field output a modified value without also modifying it on the way in.
Change History (7)
comment:1 Changed 6 years ago by
|Patch needs improvement:||unset|