How to define a foreign key in an Django app model which is ignored if a sub-app is not installed
I think you need a stub sub-app to plug the hole if it's "not installed". All it does is declare the model so that there's a table in the database (but no records). You could later replace it with the real sub-app and populate the table through it.
I have a base app which is used by sub-apps.
I have an AbstractUser defined in the base app and I need to add a relation to a sub-app model if the sub-app is installed.
I understand that my new field will be present in the user table in the database, but with a null value if the sub-app is note installed.
My problem is to reference the foreign key I had to a model that does not exists if the sub-apps is not installed.
Does I need to transfer the model from the sub-apps to the base app or is there another solution like a conditionnal foreign key constraint in my AbstractUser model.