from django.core.management.base import NoArgsCommand

from avatar.conf import settings
from avatar.models import Avatar


class Command(NoArgsCommand):
    help = ("Regenerates avatar thumbnails for the sizes specified in "
            "settings.AVATAR_AUTO_GENERATE_SIZES.")

    def handle_noargs(self, **options):
        for avatar in Avatar.objects.all():
            for size in settings.AVATAR_AUTO_GENERATE_SIZES:
                if options['verbosity'] != 0:
                    print("Rebuilding Avatar id=%s at size %s." % (avatar.id, size))

                avatar.create_thumbnail(size)

from django.core.management.base import BaseCommand

from avatar.conf import settings
from avatar.models import Avatar


class Command(BaseCommand):
    help = ("Regenerates avatar thumbnails for the sizes specified in "
            "settings.AVATAR_AUTO_GENERATE_SIZES.")

    def handle(self, *args, **options):
        for avatar in Avatar.objects.all():
            for size in settings.AVATAR_AUTO_GENERATE_SIZES:
                if options['verbosity'] != 0:
                    print("Rebuilding Avatar id=%s at size %s." % (avatar.id, size))

                avatar.create_thumbnail(size)

Fix for django >= 1.10
Fix for django >= 1.10

The class django.core.management.NoArgsCommand is removed.
- from django.core.management.base import NoArgsCommand
+ from django.core.management.base import BaseCommand
  
  from avatar.conf import settings
  from avatar.models import Avatar
  
  
- class Command(NoArgsCommand):
+ class Command(BaseCommand):
      help = ("Regenerates avatar thumbnails for the sizes specified in "
              "settings.AVATAR_AUTO_GENERATE_SIZES.")
  
-     def handle_noargs(self, **options):
+     def handle(self, *args, **options):
          for avatar in Avatar.objects.all():
              for size in settings.AVATAR_AUTO_GENERATE_SIZES:
                  if options['verbosity'] != 0:
                      print("Rebuilding Avatar id=%s at size %s." % (avatar.id, size))
  
                  avatar.create_thumbnail(size)
  
Fix for django >= 1.10
## Code Before:
from django.core.management.base import NoArgsCommand

from avatar.conf import settings
from avatar.models import Avatar


class Command(NoArgsCommand):
    help = ("Regenerates avatar thumbnails for the sizes specified in "
            "settings.AVATAR_AUTO_GENERATE_SIZES.")

    def handle_noargs(self, **options):
        for avatar in Avatar.objects.all():
            for size in settings.AVATAR_AUTO_GENERATE_SIZES:
                if options['verbosity'] != 0:
                    print("Rebuilding Avatar id=%s at size %s." % (avatar.id, size))

                avatar.create_thumbnail(size)

## Instruction:
Fix for django >= 1.10
## Code After:
from django.core.management.base import BaseCommand

from avatar.conf import settings
from avatar.models import Avatar


class Command(BaseCommand):
    help = ("Regenerates avatar thumbnails for the sizes specified in "
            "settings.AVATAR_AUTO_GENERATE_SIZES.")

    def handle(self, *args, **options):
        for avatar in Avatar.objects.all():
            for size in settings.AVATAR_AUTO_GENERATE_SIZES:
                if options['verbosity'] != 0:
                    print("Rebuilding Avatar id=%s at size %s." % (avatar.id, size))

                avatar.create_thumbnail(size)
