'How to change display value for one to one field in django admin?

I'm looking to change the display value for a one to one field in the django admin dashboard. I want to prefix the user's name to the one to one field.

I'm able to successfully do it for a foreign key like this:

 def formfield_for_foreignkey(self, db_field, request, **kwargs):
        if db_field.name == 'audio_module':
            return AudioModuleChoiceField(
                queryset=AudioModule.objects.filter(is_deleted=False).order_by('user__last_name')
            )
        return super().formfield_for_foreignkey(db_field, request, **kwargs)

However, I don't see any options in the docs to override a formfield_for_onetoone.

Currently, my form field looks like this: enter image description here

audio_module has a FK to my user table. Like I said above, I'd like to prefix the user's name in front of the audio module in the dropdown so it'll be easier to identify audio modules for specific users.

i.e. John Doe - audio module 2

How do I achieve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source