Closed TurnrDev closed 4 years ago
My version:
cities = City.objects.filter(name_local__isnull=True)
for instance in cities:
lang = instance.country.language_codes.split(',')[0]
if lang:
alt_name = instance.alt_names.filter(language_code=lang).order_by('-is_preferred').first()
name_local = alt_name.name if alt_name else instance.name
City.objects.filter(pk=instance.pk).update(name_local=name_local)
Checklist
master
branch of django-cities.