Changes between Initial Version and Version 1 of Ticket #24742, comment 3


Ignore:
Timestamp:
May 7, 2015, 11:30:22 AM (10 years ago)
Author:
andrei kulakov

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #24742, comment 3

    initial v1  
    11Adding a router that redirects migrations to a different db is exactly what I did for a recent project, - it works just fine.
     2
     3[edit] After looking it up, I did the reverse: I defined default writable db and set up routers for all read-only dbs:
     4
     5class AppRouter(object):
     6    app_name = None
     7    def db_for_read(self, model, **hints):
     8        if model._meta.app_label == self.app_name:
     9            return self.app_name
     10        return None
     11
     12class ReadonlyRouter(AppRouter):
     13    app_name = 'my_ro_app'
Back to Top