In Django, in a project using multiple databases and given a model object, how can I find out the name of the database (corresponding to the names used in using
and configured in settings.DATABASES
) the object is from?
You can do: <object>._state.db
to get the database the object is stored in.
Also here is the documentation (no very obvious though.. )