def get_next_available_revision_label(self): # type: () -> str highest_label = 'A' for r in self.get_revisions(True, True): highest_label = r.label return base26_encode(base26_decode(highest_label) + 1)
def handle(self, *args, **options): images = Image.objects.exclude(imagerevision=None).order_by('id') for i in images: count = 0 for r in i.imagerevision_set.all().order_by('id'): r.label = base26_encode(count) r.save(keep_deleted=True) count += 1 print("Processed %d images." % images.count())