Answer the question
In order to leave comments, you need to log in
How to organize migration in Django for two related models with automatic substitution of default field values?
Consider the example of Django, but the question is about any ORM. Suppose there is a production base with some data in it. it is necessary to carry out migration in the following tricky case.
There is a model, let's say Model, it has foregin keys for other models.
class ModelA: ...
class ModelX: ...
class Model:
a = models.ForeignKey(ModelA, default=A)
x = models.ForeignKey(ModelX, default=X)
class ModelY: ...
class Model:
y = models.ForeignKey(ModelY, default=??????)
Answer the question
In order to leave comments, you need to log in
The scenario for dzhanga I would suggest is this:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question