1- title: django.core.management.base BaseCommand Examples
1+ title: django.core.management.base BaseCommand Code Examples
22category: page
33slug: django-core-management-base-basecommand-examples
44sortorder: 50018
@@ -7,7 +7,6 @@ sidebartitle: django.core.management.base BaseCommand
77meta: Python code examples for Django management commands.
88
99
10- # django.core.management.base BaseCommand Examples
1110[ BaseCommand] ( https://github.com/django/django/blob/master/django/core/management/base.py )
1211is a [ Django] ( /django.html ) object for creating new Django admin commands
1312that can be invoked with the ` manage.py ` script. The Django project team
@@ -42,24 +41,26 @@ from filer.models.imagemodels import Image
4241~~ def handle (self , * args , ** options ):
4342 """
4443 Generates image thumbnails
45- NOTE : To keep memory consumption stable avoid iteration over the Image queryset
44+ NOTE : To keep memory consumption stable avoid iteration
45+ over the Image queryset
4646 """
4747 pks = Image.objects.all().values_list(' id' , flat = True )
4848 total = len (pks)
4949 for idx, pk in enumerate (pks):
5050 image = None
5151 try :
5252 image = Image.objects.get(pk = pk)
53- self .stdout.write(u ' Processing image {0} / {1} {2} ' .format(idx + 1 , total, image))
53+ self .stdout.write(u ' Processing image {0} / {1} {2} ' .\
54+ format (idx + 1 , total, image))
5455 self .stdout.flush()
5556 image.thumbnails
5657 image.icons
5758 except IOError as e:
58- self .stderr.write(' Failed to generate thumbnails: {0} ' .format(str (e)))
59+ self .stderr.write(' Failed to generate thumbnails: {0} ' \
60+ .format(str (e)))
5961 self .stderr.flush()
6062 finally :
6163 del image
6264```
6365
6466
65-
0 commit comments