If you have multiple implementations for one interface (e.g., a "TestDB" and a "LiveDB"), use a Module to specify which one to use.
For further details, consult the official Injector documentation . Make Your Django Project Less Confusing with Design Pattern injector.py
: Use the @provider decorator inside a Module for more complex object creation that requires logic. If you have multiple implementations for one interface (e
from injector import Injector injector = Injector([MyModule()]) # Pass your modules here service = injector.get(Service) # Automatically creates Database and Service print(service.db.status) # "Connected" Use code with caution. Copied to clipboard a "TestDB" and a "LiveDB")