def assign_regions(resource):
 for i in range(0, randint(0, 5)):
  random_index = randint(0, (Region.objects.all().count() - 1))
  region = Region.objects.all()[random_index]
  resource.regions.add(region)

def assign_regions ( resource ) : for i in range ( 0 , randint ( 0 , 5 ) ) : random_index = randint ( 0 , ( Region . objects . all ( ) . count ( ) - 1 ) ) region = Region . objects . all ( ) [ random_index ] resource . regions . add ( region )
assign up to 5 regions to resource .