def deduplicate_countries(country, dup_country):
 regions = dup_country.region_set.all()
 if regions.exists():
  regions.update(country=country)
 cities = dup_country.city_set.all()
 if cities.exists():
  cities.update(country=country)
 users = dup_country.userprofile_set.all()
 if users.exists():
  users.update(geo_country=country)
 dup_country.delete()

def deduplicate_countries ( country , dup_country ) : regions = dup_country . region_set . all ( ) if regions . exists ( ) : regions . update ( country = country ) cities = dup_country . city_set . all ( ) if cities . exists ( ) : cities . update ( country = country ) users = dup_country . userprofile_set . all ( ) if users . exists ( ) : users . update ( geo_country = country ) dup_country . delete ( )
given 2 country instances .