My django + SQLAlchemy app uses cdecimal instead of the default decimal module.
I followed the instructions on SQLAlchemy’s website:
import sys
import cdecimal
sys.modules["decimal"] = cdecimal
Using the same from a previous stackoverflow thread, I am able to add the data to the DB. However, when I retrieve an entry from my table and look at its value, the type of value returned to me is actually decimal.Decimal rather than cdecimal.Decimal.
How do I tell SQLAlchemy to give me back cdecimal.Decimal objects when entries are retrieved?
Thanks!
The solution here is to put this code
In the manage.py file, rather than the models.py file. This ensures that cdecimal is really replacing decimal from the beginning.