auth.Message ignores directions from database router - Possible RelatedManager bug

1 view
Skip to first unread message

xin

unread,
Mar 28, 2010, 9:28:31 PM3/28/10
to Django users, al...@codex.cx
I am unsure if this a bug in Django, or django-multidb-router, or
something I've done wrong.

I'm using django-multidb-router from here: http://github.com/jbalogh/django-multidb-router
With two database definitions, a read_only_user and a read_write_user
(with the intentions of having multiple read-only definitions)

As far as I can tell, all reads get directed to the read_only_user and
all writes get detected to read_write_user. That is, until
contrib.Admin tries to create a new user message for a save() which
for tries to write with the read_only_user and fails.

When overriding auth.Message.save() with an empty function, the admin
interface resumes working as expected, with reads and writes being
sent to the appropriate databases.


From what I guess by looking at the traceback, `RelatedManager` is
overriding `get_query_set()` to set the query-set's DB. But when the
`create()` call gets down to `models.query.QuerySet.create()`,
`obj.save()` (line 350) is called, and forces `using` to self.db,
negating any direction from the Router.


Can anybody confirm it's a Django bug?

Cheers,

Russell Keith-Magee

unread,
Mar 31, 2010, 8:38:48 AM3/31/10
to django...@googlegroups.com

Apologies for not replying sooner - this message was on my todo list,
but got buried in other stuff.

I presume you are the person behind #13250 -- in which case, I just
committed a fix in r12895. It turns out it was an error in the way
routing information was used when calling create() on a foreign key
(in this case, user.message_set.create()). I've corrected the error;
let me know if you have any more problems.

Yours,
Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages