from django.core.management.base import BaseCommand

from axes.utils import reset


class Command(BaseCommand):
    help = ("resets any lockouts or failed login records. If called with an "
            "IP, resets only for that IP")

    def add_arguments(self, parser):
        parser.add_argument('ip', nargs='*')

    def handle(self, *args, **kwargs):
        count = 0
        if kwargs:
            for ip in kwargs['ip']:
                count += reset(ip=ip)
        else:
            count = reset()

        if count:
            print('{0} attempts removed.'.format(count))
        else:
            print('No attempts found.')

from django.core.management.base import BaseCommand

from axes.utils import reset


class Command(BaseCommand):
    help = ("resets any lockouts or failed login records. If called with an "
            "IP, resets only for that IP")

    def add_arguments(self, parser):
        parser.add_argument('ip', nargs='*')

    def handle(self, *args, **kwargs):
        count = 0
        if kwargs and kwargs.get('ip'):
            for ip in kwargs['ip']:
                count += reset(ip=ip)
        else:
            count = reset()

        if count:
            print('{0} attempts removed.'.format(count))
        else:
            print('No attempts found.')

Reset all attempts when ip not specified
Reset all attempts when ip not specified

When no ip address positional arguments are specified, reset all attempts, as with reset() and per documentation.
  from django.core.management.base import BaseCommand
  
  from axes.utils import reset
  
  
  class Command(BaseCommand):
      help = ("resets any lockouts or failed login records. If called with an "
              "IP, resets only for that IP")
  
      def add_arguments(self, parser):
          parser.add_argument('ip', nargs='*')
  
      def handle(self, *args, **kwargs):
          count = 0
-         if kwargs:
+         if kwargs and kwargs.get('ip'):
              for ip in kwargs['ip']:
                  count += reset(ip=ip)
          else:
              count = reset()
  
          if count:
              print('{0} attempts removed.'.format(count))
          else:
              print('No attempts found.')
  
Reset all attempts when ip not specified
## Code Before:
from django.core.management.base import BaseCommand

from axes.utils import reset


class Command(BaseCommand):
    help = ("resets any lockouts or failed login records. If called with an "
            "IP, resets only for that IP")

    def add_arguments(self, parser):
        parser.add_argument('ip', nargs='*')

    def handle(self, *args, **kwargs):
        count = 0
        if kwargs:
            for ip in kwargs['ip']:
                count += reset(ip=ip)
        else:
            count = reset()

        if count:
            print('{0} attempts removed.'.format(count))
        else:
            print('No attempts found.')

## Instruction:
Reset all attempts when ip not specified
## Code After:
from django.core.management.base import BaseCommand

from axes.utils import reset


class Command(BaseCommand):
    help = ("resets any lockouts or failed login records. If called with an "
            "IP, resets only for that IP")

    def add_arguments(self, parser):
        parser.add_argument('ip', nargs='*')

    def handle(self, *args, **kwargs):
        count = 0
        if kwargs and kwargs.get('ip'):
            for ip in kwargs['ip']:
                count += reset(ip=ip)
        else:
            count = reset()

        if count:
            print('{0} attempts removed.'.format(count))
        else:
            print('No attempts found.')
