pythondjangodjango-modelsmultiple-sites

Saving models in django


I am working on a multisite project and i am using mezzanine+cartridge for this. I want to use same inventory for both sites. But there are some issues with this: there is a field site_id in the product table which stores the ID of the current site. Thus, I cannot reuse product over sites.

Is there any way (like with the help of signals or anything) that I can save an entry twice in the database, with changes to some field's values?

If this is possible then I have to overwrite only site_id: the rest of the things remain the same as it was in the previous entry. Thereby it decreases the workload of entering products twice for different sites.

Thanks.


Solution

  • I would caution against writing the same thing twice. Some thing will definitely go wrong, and you will have two nonmatching db's. Why don't you make the site_id-product relationship M2M, so that you can have more than one site_id's?