V
V
Vladimir Kuts2021-12-28 19:39:48
Django
Vladimir Kuts, 2021-12-28 19:39:48

Return database name from using?

Let's say I have an object:

someobj = SomeObject.objects.using('db1').get(id=some_id)


How can I get the string 'db1' from the someobj object now - where did we get this object from?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Leonid, 2021-12-28
@bravebug

They asked very spherically in a vacuum:
You can inspect the attributes of an object using dir(someobj), but its attributes can also be objects
Or read the code of the called method of the class being used.
Who knows where SomeObject or possibly delegated classes put what values.
Ps: an abstract answer to an abstract question

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question