python - Dynamic database selection based on URL in Django -


let's first page of app has 2 links. possible pick database depending on link clicked? databases both have same models, different data. example, let's application contains students different colleges a , b. if link a clicked, database a used contains students college a. entire application after point should use database college a.

i understand there ways work around problem designing databases differently, i.e. having college field, , filtering out students particular college affiliation. hoping find solution using django use 2 different databases.

so need store chosen database in session or smth , can pick database. docs

>>> # run on 'default' database. >>> author.objects.all()  >>> # this. >>> author.objects.using('default').all()  >>> # run on 'other' database. >>> author.objects.using('other').all() 

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -