问题
Hi is there a way that i can use a same *inventory* for multiple *sites* in django. I am using the cartridge in django with mezanine.I need to create a multisite project with single cartridge.
回答1:
I think you can try to use multiple databases with router:
DATABASES = {
'default': {
...
},
'cartridge': {
'NAME': 'cartridge_data',
...
}
}
class CartridgeRouter(object):
def db_for_read(self, model, **hints):
if model._meta.app_label == 'cartridge':
return 'cartridge'
return 'default'
def db_for_write(self, model, **hints):
if model._meta.app_label == 'cartridge':
return 'cartridge'
return 'default'
来源:https://stackoverflow.com/questions/14313538/use-same-inventory-for-multiple-sites-in-django-python