[Fixed]-How should multiple Django apps communicate with each other?

7👍

I would definitely go for the importing Processor’s models in the Presenter app. That’s how, for instance, you can add extra user info: you have a UserPreferences model with a ForeignKeyField to django.contrib.auth.models.User. Your might have less of a bad feeling doing that that between your two apps because django.contrib is the “standard library”, but nevertheless, it is direct coupling.

If your applications are coupled, then your code should be coupled to reflect this. This follows the idea that explicit is better than implicit, right?

If, however, your’re designing something a tad more generic (i.e. you’re going to use multiple Presenter app instances for Processors of different kinds), you can store the specific models as a setting:

import processor_x.models
PRESENTER_PROCESSOR_MODELS = presenter_x.models

Then, in your Presenter models:

from django.conf import settings
class Presenter:
    processor = models.ForeignKey(settings.PRESENTER_PROCESSOR_MODELS)

Caveat: I have never attempted this, but I don’t recall a limitation on settings to be only strings, tuples or lists!

Leave a comment