[Fixed]-How to find the database a Django record was loaded from?

1👍

_state seems to hold what you’re looking for.

record._state.db

If you’re interested, it’s used internally in the source code here: https://docs.djangoproject.com/en/dev/_modules/django/db/models/base/

👤munsu

Leave a comment