Our site has two separate projects connected to the same database. This is implemented by importing the models from project1 into project2 and using it to access an开发者_运维问答d manipulate data.
This works fine on our test server, but we are planning deployment and we decided we would rather have the projects on two separate machines, with the database on a third one.
I have been looking around for ideas on how to import the model from a project on another machine but that doesn't seem to be possible. An obvious solution would be to put the models in a separate app and have it on both boxes, but that means code is duplicated and changes have to be applied twice.
I'm looking for suggestions on how to deal with this and am wondering if other people have encountered similar issues. We'll be deploying on AWS if that helps. Thanks.
This isn't really a Django question. It is more a Python Question.
However to answer your question Django is going to have to be able to import these files one way or another. If they are on seperate machines you really should refactor the code out into it's own app and then install this app on each of the machines.
The only other way I can think of to do this is to make your own import hook that can import a file from across a network but that is a really bad idea for a multitude of reasons.
精彩评论