class DecoupledModel(models.Model):

    class Meta:
        abstract = True

    _linked_fields = {
        # 'field': MyModel,
    }

    def __getattr__(self, name):
        fields = self.__class__._linked_fields
        if name in fields:
            model_class = fields[name]
            model = None
            try:
                pk = getattr(self, name + '_id')
                if pk:
                    model = model_class.objects.get(pk = pk)
            except:
                pass
            self.__dict__[name] = model
            return model
        else:
            return super(DecoupledModel, self).__getattribute__(name)

    def __setattr__(self, name, value):
        fields = self.__class__._linked_fields
        if name in fields:
            pk = 0
            try:
                if value:
                    pk = value.pk
            except:
                pass
            self.__dict__[name + '_id'] = pk
            self.__dict__[name] = value
            return pk
        else:
            return super(DecoupledModel, self).__setattr__(name, value)