from django.core.management.base import BaseCommand def command(help=None, args=''): def _decorate(func): _args = args _help = help class Command(BaseCommand): help = _help if _help is not None else func.__doc__ args = _args def handle(self, *args, **kwargs): return func(*args, **kwargs) func.func_globals['Command'] = Command return func return _decorate