A much easier approach than building and executing the code as a string would be to access the attribute using the built-in getattr function. This makes it clearer what's going on and side-steps your current scope issues entirely:

objects = getattr(md, aux_type + 's').all()

Python has extensive support for this kind of introspection; using exec (and eval) is usually a warning that you're approaching something in the wrong way.