I'm trying to make a (Django) query to my database using the following syntax:
Derp.objects.all()
I have a production database and a default (development) database. So obviously, by default, that query above will use the default database.
I'm having trouble figuring out how to select my other database. A coworker suggested the following:
Derp.objects.all(using="development")
But that returns a TypeError:
all() got an unexpected keyword argument 'using'
Can someone tell me what the proper syntax is? I can't seem to find what parameters the all() method will actually accept.
-
The syntax and wording look like you are using the Django ORM. If so it would be helpful to know what version.Mark Lavin– Mark Lavin2011年12月27日 18:45:14 +00:00Commented Dec 27, 2011 at 18:45
-
@MarkLavin django.VERSION prints (1, 3, 0, 'final', 0)tnw– tnw2011年12月27日 18:52:15 +00:00Commented Dec 27, 2011 at 18:52
1 Answer 1
Your syntax is slightly off:
Derp.objects.using('production').all()
Obviously, the 'production' key needs to match whatever you've labeled your DB in settings.py.