﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20337	ValueError when database router prevents relation is unclear	Dan Loewenherz	Tim Graham <timograham@…>	"I'm using a custom database router to manage queries between two databases.

In my router, the `allow_relation` method was set incorrectly, and as a result, two models from separate apps weren't allowed to reference each other. The ValueError I received looked like this:

{{{
Cannot assign ""<ContentType: xxx>"": instance is on database ""default"", value is on database ""default
}}}

I opened up the source that raised this error, and saw this line:

{{{
if not router.allow_relation(value, instance):
    raise ValueError('Cannot assign ""%r"": instance is on database ""%s"", value is on database ""%s""' % (value, instance._state.db, value._state.db))
}}}

The databases that these objects are on had nothing to do with how my router was routing the query, and kind of led me on a wild goose chase until I opened up the source. I would suggest a copy change to something like: ""Cannot assign ""%r"": the current database router prevents this relation."""	Cleanup/optimization	closed	Database layer (models, ORM)	dev	Normal	fixed	router		Accepted	0	0	0	0	1	0
