def populate_uuids(apps, schema_editor):
 Document = apps.get_model(u'wiki', u'Document')
 docs = Document.objects.filter(uuid__isnull=True)
 for document_id in docs.values_list(u'id', flat=True).iterator():
  Document.objects.filter(id=document_id).update(uuid=uuid4())

def populate_uuids ( apps , schema_editor ) : Document = apps . get_model ( u'wiki' , u'Document' ) docs = Document . objects . filter ( uuid__isnull = True ) for document_id in docs . values_list ( u'id' , flat = True ) . iterator ( ) : Document . objects . filter ( id = document_id ) . update ( uuid = uuid4 ( ) )
populate document .