Reputation: 711
is it possible to have on the same admin command class option to run it with or without args.
like having if args == "" (run this command) else: (run this)?
Thanks in advance.
Upvotes: 1
Views: 1991
Reputation: 1864
Sure, just check 'args' as passed to the handle method like this:
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = 'prints no args if there are no args'
def handle(self, *args, **options):
if len(args) == 0:
print 'no args'
else:
for pkid in args:
print pkid
Upvotes: 3