fromdjango.core.management.baseimportBaseCommandfromdjango.dbimporttransactionfrommemopol.utilsimportprogress_barfromrepresentatives.modelsimportRepresentativefrommemopol_representatives.modelsimportMemopolRepresentativeclassCommand(BaseCommand):@transaction.atomicdefhandle(self,*args,**options):n=Representative.objects.all().count()fori,representativeinenumerate(Representative.objects.all()):memopol_representative=MemopolRepresentative(representative_ptr=representative)memopol_representative.__dict__.update(representative.__dict__)# Auto set active flag of the memopol representativememopol_representative.update_active()progress_bar(i,n)