Skip to content

Change country order based on user language #418

@HenryMehta

Description

@HenryMehta

I have a Django app which django-countries. I would like to alter the order of the countries shown based on the user's language. For example if the user is using French, I will bring France, Belgium, Luxumburg, Switzerland etc to the top, whereas if they select German I will bring up Germany, Austria, Switzerland etc.

I can set COUNTRIES_FIRST = ['FR','BE','LU','CH'] within settings, but that ordering is then used for all user languages.

Is there a way to base the order on the user's language?

I have tried modifying the COUNTRIES_FIRST within a view, for example

    if self.administration_instance.study.instrument.language == 'French':
        settings.COUNTRIES_FIRST = ['FR','CH','BE','LU']
    translation.activate(self.user_language)

But this clearly doesn't work

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions