Use same inventory for multiple sites in django python

此生再无相见时 提交于 2019-12-12 03:09:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!