I need to combine two instances of a model, and the process I need to go through is fairly simple. There’s no much if any normalized data in the system. To combine the two I would just need to merge the data, and set the relevant foreign_keys on any models related.
The issue comes in trying to keep the app as ‘reusable’ as possible. I don’t want to edit this module any time I add another model which might work with this one. is there a way to get a list of models with a foreign key to another specific model? and what the relevant fields are?
Also, a number of links back to this root model would be through generic foreign keys. Hoever I’m assuming finding the models linking to the root object would work on finding models linking to the ContentTypes model.
You might be able to pull this off via introspection, but you are tightly coupling your models to the Django implementation, which could be dangerous. If you are good with that, you could do something along the lines of:
Might not be the best solution, but it seems to work in testing.