python – How do I integrate a repository into Django automatically, via submodule or other package?


I have a project in Django that has grown quite a bit and is on Git. Specifically, there is a part of the project, an adapter, that requires constant releases, while the rest of the code is quite stable.

Performing releases of the entire repository each time implies different things that are a bit tedious: although I have it automated, it implies restarting services and different topics.

So I am considering separating the adapter into a new repository. Looking at options, I see that I can either package the adapter and import it as another module or use a submodule. After comparing options, I am quite determined to use the second option, that of submodules.

So now I would find myself in this situation: repository A with submodule B. When I release submodule B, I find that I have to go to repository A and do git submodule update --recursive --remote so that the content is updated. .. and then do all the services restart etc. I mean, what I wanted to avoid.

Is there an option for a module to automatically use the latest version from a different sub-module or repository? Or, indeed, will it always be necessary to update from the module? Is there any other option for this situation?


While it is true that a microservice could solve the problem, since the microservice is restarted and the server does not need to be restarted, I don't know what it means for your code and how much you should modify.

Another option is that you can reload a module after it has been imported using the reload function of the importlib library implemented in python 3.4

from importlib import reload  
import submodule

submodule = reload(submodule)

You should only run the line submodule = reload(submodule) at the time you need to reload your module.

Taking into account that it is Django, the Django server is updated every time something changes, so I don't know if it applies to this case.

Scroll to Top