I am running two projects printing and inspection as services in Docker which both are using django as a backend.I want to access a model from printing(printing.status.models import Count) in my inspection project as
from printing.status.models import Count
is it possible or should i try another approach for this…
Are you running two projects individually or are you running single project and created two apps printing and inspection and want to import models defined in printing to inspection views.
I am running two projects individually in docker as a service.
If they are two separate projects with two separate code bases, then you will need to copy the model definition from one project to the other.
If there’s other significant code-overlap between the two, you might think of combining those projects into a single source code base.
Or, you could refactor part of it out into a separate installable package that is installed into each deployment.
But there’s no direct way to access the model definition from a completely separate and independent project.
can you explain me on the first approach that you mentioned.
what i understand from the first approach is Copying the model of one codebase to another codebase but will it give me migrations issue when i am migrating because both are connected and using the same database.
I would suggest you use the
managed = False attribute in the
Meta class of the copied version. That way it won’t try to create or apply migrations to that model.
Thanks for the advice.
I will implement the solution and let you know if there are any issues in that.
I just want to know is it possible to access a model in A from B using django-cors-headers.
This is the article that I encountered link.
If it is possible how to access it from from project B it is mentioned how to setup in Project. A
But in the situation you described originally, where projects A and B share the same database, you don’t need to create an API for this purpose.