On Tue, Oct 11, 2011 at 3:47 PM, Sells, Fred <fred.se...@adventistcare.org> wrote: > I'm using a MySQL database and one table resides in a separate database > than all the others. It's a generic logging table. > > I understand the use of the .using() method, but I wonder if there is a > way to specify the alternative model in the model definition so I don't > have to depend on remembering to add the .using() method in any usage. > > I could create a view in mysql and make the model "unmanaged" but was > wondering if there is a more pythonic way?
Indeed there is: what you're looking for is called a "database router", and you can find documentation here: https://docs.djangoproject.com/en/dev/topics/db/multi-db/#automatic-database-routing In your particular case, you'll implement something very similar to the first example presented there: if the app is your logging app, use the logging connection; otherwise, use the default connection. Jacob -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.