Hi David
Your router isn't configured correctly. This applies to all the
allow_foo() methods, but see allow_migrate [1] as an example:
Determine if the migration operation is allowed to run on the
database with alias db. Return True if the operation should run, False
if it shouldn’t run, or None if the router has no opinion.
Your routers *should* be having an opinion about whether that
app/model can be migrated on a specific database! For instance, you
say "the last app" should stay only on validations, but what your
ValidationRouter says is "If the app label is called fourth_model, run
migrations on this database", but it never checks what the database
is.
For ValidationRouter.allow_migrate you probably want something like this:
def allow_migrate(self, ...):
if app_label == "fourth_model":
return db == "validations"
elif db == "validations":
return False
EG:
* if the app label is an app that should be in the validations DB,
allow migrate when the db is the validations DB
* if it isn't and the DB is the validations DB, don't allow migrations to it
* if neither of those things, this router doesn't care.
Similarly, for allow_relations() you should be returning False when
the models should not be related.
Incidentally, all python functions return None if the end of the
function is reached without an explicit return value, so you never
have to end your functions with an explicit "return None".
Cheers
Tom
[1]
https://docs.djangoproject.com/en/2.1/topics/db/multi-db/#allow_migrate
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
django-users...@googlegroups.com.
> To post to this group, send email to
django...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/8eef7cfe-93ed-4322-ab84-09261e27f460%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.