Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does this still support using? #10

Open
allidoisace opened this issue Mar 22, 2019 · 1 comment
Open

Does this still support using? #10

allidoisace opened this issue Mar 22, 2019 · 1 comment

Comments

@allidoisace
Copy link

allidoisace commented Mar 22, 2019

If I have a block like so, is this still acceptable?

with in_database('external'): MyModel.objects.using('other_db').filter(field='value')

@luisbello30
Copy link

luisbello30 commented Oct 25, 2022

I know it's been a long time but in case someone needs it

use an alias

db_connection = {'NAME': 'name', 'USER': 'user', 'PASSWORD': 'password', 'HOST': '127.0.0.1', 'PORT': 5432, 'ENGINE': 'django.db.backends.postgresql'}

with in_database(db_connection) as data_base_config:
    new_db = data_base_config.database
    return MyModel.objects.using(new_db).filter(field='value')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants