prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Show full usernames when filtering
  ### NetBox version
  
  v3.1.9
  
  ### Feature type
  
  Change to existing functionality
  
  ### Proposed functionality
  
  When using the filters to filter user-based (e.g. Journal and Changelog), the full user name should be displayed in brackets, instead of just the login name.
  
  ### Use case
  
  Makes filtering in big installations easier
  
  ### Database changes
  
  None, all data is already in netbox
  
  ### External dependencies
  
  None
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `netbox/users/api/nested_serializers.py`
  Content:
  ```
  1 from django.contrib.auth.models import Group, User
  2 from django.contrib.contenttypes.models import ContentType
  3 from rest_framework import serializers
  4 
  5 from netbox.api import ContentTypeField, WritableNestedSerializer
  6 from users.models import ObjectPermission, Token
  7 
  8 __all__ = [
  9     'NestedGroupSerializer',
  10     'NestedObjectPermissionSerializer',
  11     'NestedTokenSerializer',
  12     'NestedUserSerializer',
  13 ]
  14 
  15 
  16 class NestedGroupSerializer(WritableNestedSerializer):
  17     url = serializers.HyperlinkedIdentityField(view_name='users-api:group-detail')
  18 
  19     class Meta:
  20         model = Group
  21         fields = ['id', 'url', 'display', 'name']
  22 
  23 
  24 class NestedUserSerializer(WritableNestedSerializer):
  25     url = serializers.HyperlinkedIdentityField(view_name='users-api:user-detail')
  26 
  27     class Meta:
  28         model = User
  29         fields = ['id', 'url', 'display', 'username']
  30 
  31 
  32 class NestedTokenSerializer(WritableNestedSerializer):
  33     url = serializers.HyperlinkedIdentityField(view_name='users-api:token-detail')
  34 
  35     class Meta:
  36         model = Token
  37         fields = ['id', 'url', 'display', 'key', 'write_enabled']
  38 
  39 
  40 class NestedObjectPermissionSerializer(WritableNestedSerializer):
  41     url = serializers.HyperlinkedIdentityField(view_name='users-api:objectpermission-detail')
  42     object_types = ContentTypeField(
  43         queryset=ContentType.objects.all(),
  44         many=True
  45     )
  46     groups = serializers.SerializerMethodField(read_only=True)
  47     users = serializers.SerializerMethodField(read_only=True)
  48 
  49     class Meta:
  50         model = ObjectPermission
  51         fields = ['id', 'url', 'display', 'name', 'enabled', 'object_types', 'groups', 'users', 'actions']
  52 
  53     def get_groups(self, obj):
  54         return [g.name for g in obj.groups.all()]
  55 
  56     def get_users(self, obj):
  57         return [u.username for u in obj.users.all()]
  58
  ```
  
  Path: `netbox/users/api/serializers.py`
  Content:
  ```
  1 from django.contrib.auth.models import Group, User
  2 from django.contrib.contenttypes.models import ContentType
  3 from rest_framework import serializers
  4 
  5 from netbox.api import ContentTypeField, SerializedPKRelatedField, ValidatedModelSerializer
  6 from users.models import ObjectPermission, Token
  7 from .nested_serializers import *
  8 
  9 
  10 __all__ = (
  11     'GroupSerializer',
  12     'ObjectPermissionSerializer',
  13     'TokenSerializer',
  14     'UserSerializer',
  15 )
  16 
  17 
  18 class UserSerializer(ValidatedModelSerializer):
  19     url = serializers.HyperlinkedIdentityField(view_name='users-api:user-detail')
  20     groups = SerializedPKRelatedField(
  21         queryset=Group.objects.all(),
  22         serializer=NestedGroupSerializer,
  23         required=False,
  24         many=True
  25     )
  26 
  27     class Meta:
  28         model = User
  29         fields = (
  30             'id', 'url', 'display', 'username', 'password', 'first_name', 'last_name', 'email', 'is_staff', 'is_active',
  31             'date_joined', 'groups',
  32         )
  33         extra_kwargs = {
  34             'password': {'write_only': True}
  35         }
  36 
  37     def create(self, validated_data):
  38         """
  39         Extract the password from validated data and set it separately to ensure proper hash generation.
  40         """
  41         password = validated_data.pop('password')
  42         user = super().create(validated_data)
  43         user.set_password(password)
  44         user.save()
  45 
  46         return user
  47 
  48 
  49 class GroupSerializer(ValidatedModelSerializer):
  50     url = serializers.HyperlinkedIdentityField(view_name='users-api:group-detail')
  51     user_count = serializers.IntegerField(read_only=True)
  52 
  53     class Meta:
  54         model = Group
  55         fields = ('id', 'url', 'display', 'name', 'user_count')
  56 
  57 
  58 class TokenSerializer(ValidatedModelSerializer):
  59     url = serializers.HyperlinkedIdentityField(view_name='users-api:token-detail')
  60     key = serializers.CharField(min_length=40, max_length=40, allow_blank=True, required=False)
  61     user = NestedUserSerializer()
  62 
  63     class Meta:
  64         model = Token
  65         fields = ('id', 'url', 'display', 'user', 'created', 'expires', 'key', 'write_enabled', 'description')
  66 
  67     def to_internal_value(self, data):
  68         if 'key' not in data:
  69             data['key'] = Token.generate_key()
  70         return super().to_internal_value(data)
  71 
  72 
  73 class TokenProvisionSerializer(serializers.Serializer):
  74     username = serializers.CharField()
  75     password = serializers.CharField()
  76 
  77 
  78 class ObjectPermissionSerializer(ValidatedModelSerializer):
  79     url = serializers.HyperlinkedIdentityField(view_name='users-api:objectpermission-detail')
  80     object_types = ContentTypeField(
  81         queryset=ContentType.objects.all(),
  82         many=True
  83     )
  84     groups = SerializedPKRelatedField(
  85         queryset=Group.objects.all(),
  86         serializer=NestedGroupSerializer,
  87         required=False,
  88         many=True
  89     )
  90     users = SerializedPKRelatedField(
  91         queryset=User.objects.all(),
  92         serializer=NestedUserSerializer,
  93         required=False,
  94         many=True
  95     )
  96 
  97     class Meta:
  98         model = ObjectPermission
  99         fields = (
  100             'id', 'url', 'display', 'name', 'description', 'enabled', 'object_types', 'groups', 'users', 'actions',
  101             'constraints',
  102         )
  103
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/netbox/users/api/nested_serializers.py b/netbox/users/api/nested_serializers.py
  --- a/netbox/users/api/nested_serializers.py
  +++ b/netbox/users/api/nested_serializers.py
  @@ -28,6 +28,11 @@
           model = User
           fields = ['id', 'url', 'display', 'username']
   
  +    def get_display(self, obj):
  +        if full_name := obj.get_full_name():
  +            return f"{obj.username} ({full_name})"
  +        return obj.username
  +
   
   class NestedTokenSerializer(WritableNestedSerializer):
       url = serializers.HyperlinkedIdentityField(view_name='users-api:token-detail')
  diff --git a/netbox/users/api/serializers.py b/netbox/users/api/serializers.py
  --- a/netbox/users/api/serializers.py
  +++ b/netbox/users/api/serializers.py
  @@ -44,6 +44,11 @@
           user.save()
   
           return user
  +    
  +    def get_display(self, obj):
  +        if full_name := obj.get_full_name():
  +            return f"{obj.username} ({full_name})"
  +        return obj.username
   
   
   class GroupSerializer(ValidatedModelSerializer):
  
verification_info: {"golden_diff": "diff --git a/netbox/users/api/nested_serializers.py b/netbox/users/api/nested_serializers.py\n--- a/netbox/users/api/nested_serializers.py\n+++ b/netbox/users/api/nested_serializers.py\n@@ -28,6 +28,11 @@\n         model = User\n         fields = ['id', 'url', 'display', 'username']\n \n+    def get_display(self, obj):\n+        if full_name := obj.get_full_name():\n+            return f\"{obj.username} ({full_name})\"\n+        return obj.username\n+\n \n class NestedTokenSerializer(WritableNestedSerializer):\n     url = serializers.HyperlinkedIdentityField(view_name='users-api:token-detail')\ndiff --git a/netbox/users/api/serializers.py b/netbox/users/api/serializers.py\n--- a/netbox/users/api/serializers.py\n+++ b/netbox/users/api/serializers.py\n@@ -44,6 +44,11 @@\n         user.save()\n \n         return user\n+    \n+    def get_display(self, obj):\n+        if full_name := obj.get_full_name():\n+            return f\"{obj.username} ({full_name})\"\n+        return obj.username\n \n \n class GroupSerializer(ValidatedModelSerializer):\n", "issue": "Show full usernames when filtering\n### NetBox version\n\nv3.1.9\n\n### Feature type\n\nChange to existing functionality\n\n### Proposed functionality\n\nWhen using the filters to filter user-based (e.g. Journal and Changelog), the full user name should be displayed in brackets, instead of just the login name.\n\n### Use case\n\nMakes filtering in big installations easier\n\n### Database changes\n\nNone, all data is already in netbox\n\n### External dependencies\n\nNone\n", "before_files": [{"content": "from django.contrib.auth.models import Group, User\nfrom django.contrib.contenttypes.models import ContentType\nfrom rest_framework import serializers\n\nfrom netbox.api import ContentTypeField, WritableNestedSerializer\nfrom users.models import ObjectPermission, Token\n\n__all__ = [\n    'NestedGroupSerializer',\n    'NestedObjectPermissionSerializer',\n    'NestedTokenSerializer',\n    'NestedUserSerializer',\n]\n\n\nclass NestedGroupSerializer(WritableNestedSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:group-detail')\n\n    class Meta:\n        model = Group\n        fields = ['id', 'url', 'display', 'name']\n\n\nclass NestedUserSerializer(WritableNestedSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:user-detail')\n\n    class Meta:\n        model = User\n        fields = ['id', 'url', 'display', 'username']\n\n\nclass NestedTokenSerializer(WritableNestedSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:token-detail')\n\n    class Meta:\n        model = Token\n        fields = ['id', 'url', 'display', 'key', 'write_enabled']\n\n\nclass NestedObjectPermissionSerializer(WritableNestedSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:objectpermission-detail')\n    object_types = ContentTypeField(\n        queryset=ContentType.objects.all(),\n        many=True\n    )\n    groups = serializers.SerializerMethodField(read_only=True)\n    users = serializers.SerializerMethodField(read_only=True)\n\n    class Meta:\n        model = ObjectPermission\n        fields = ['id', 'url', 'display', 'name', 'enabled', 'object_types', 'groups', 'users', 'actions']\n\n    def get_groups(self, obj):\n        return [g.name for g in obj.groups.all()]\n\n    def get_users(self, obj):\n        return [u.username for u in obj.users.all()]\n", "path": "netbox/users/api/nested_serializers.py"}, {"content": "from django.contrib.auth.models import Group, User\nfrom django.contrib.contenttypes.models import ContentType\nfrom rest_framework import serializers\n\nfrom netbox.api import ContentTypeField, SerializedPKRelatedField, ValidatedModelSerializer\nfrom users.models import ObjectPermission, Token\nfrom .nested_serializers import *\n\n\n__all__ = (\n    'GroupSerializer',\n    'ObjectPermissionSerializer',\n    'TokenSerializer',\n    'UserSerializer',\n)\n\n\nclass UserSerializer(ValidatedModelSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:user-detail')\n    groups = SerializedPKRelatedField(\n        queryset=Group.objects.all(),\n        serializer=NestedGroupSerializer,\n        required=False,\n        many=True\n    )\n\n    class Meta:\n        model = User\n        fields = (\n            'id', 'url', 'display', 'username', 'password', 'first_name', 'last_name', 'email', 'is_staff', 'is_active',\n            'date_joined', 'groups',\n        )\n        extra_kwargs = {\n            'password': {'write_only': True}\n        }\n\n    def create(self, validated_data):\n        \"\"\"\n        Extract the password from validated data and set it separately to ensure proper hash generation.\n        \"\"\"\n        password = validated_data.pop('password')\n        user = super().create(validated_data)\n        user.set_password(password)\n        user.save()\n\n        return user\n\n\nclass GroupSerializer(ValidatedModelSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:group-detail')\n    user_count = serializers.IntegerField(read_only=True)\n\n    class Meta:\n        model = Group\n        fields = ('id', 'url', 'display', 'name', 'user_count')\n\n\nclass TokenSerializer(ValidatedModelSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:token-detail')\n    key = serializers.CharField(min_length=40, max_length=40, allow_blank=True, required=False)\n    user = NestedUserSerializer()\n\n    class Meta:\n        model = Token\n        fields = ('id', 'url', 'display', 'user', 'created', 'expires', 'key', 'write_enabled', 'description')\n\n    def to_internal_value(self, data):\n        if 'key' not in data:\n            data['key'] = Token.generate_key()\n        return super().to_internal_value(data)\n\n\nclass TokenProvisionSerializer(serializers.Serializer):\n    username = serializers.CharField()\n    password = serializers.CharField()\n\n\nclass ObjectPermissionSerializer(ValidatedModelSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:objectpermission-detail')\n    object_types = ContentTypeField(\n        queryset=ContentType.objects.all(),\n        many=True\n    )\n    groups = SerializedPKRelatedField(\n        queryset=Group.objects.all(),\n        serializer=NestedGroupSerializer,\n        required=False,\n        many=True\n    )\n    users = SerializedPKRelatedField(\n        queryset=User.objects.all(),\n        serializer=NestedUserSerializer,\n        required=False,\n        many=True\n    )\n\n    class Meta:\n        model = ObjectPermission\n        fields = (\n            'id', 'url', 'display', 'name', 'description', 'enabled', 'object_types', 'groups', 'users', 'actions',\n            'constraints',\n        )\n", "path": "netbox/users/api/serializers.py"}], "after_files": [{"content": "from django.contrib.auth.models import Group, User\nfrom django.contrib.contenttypes.models import ContentType\nfrom rest_framework import serializers\n\nfrom netbox.api import ContentTypeField, WritableNestedSerializer\nfrom users.models import ObjectPermission, Token\n\n__all__ = [\n    'NestedGroupSerializer',\n    'NestedObjectPermissionSerializer',\n    'NestedTokenSerializer',\n    'NestedUserSerializer',\n]\n\n\nclass NestedGroupSerializer(WritableNestedSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:group-detail')\n\n    class Meta:\n        model = Group\n        fields = ['id', 'url', 'display', 'name']\n\n\nclass NestedUserSerializer(WritableNestedSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:user-detail')\n\n    class Meta:\n        model = User\n        fields = ['id', 'url', 'display', 'username']\n\n    def get_display(self, obj):\n        if full_name := obj.get_full_name():\n            return f\"{obj.username} ({full_name})\"\n        return obj.username\n\n\nclass NestedTokenSerializer(WritableNestedSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:token-detail')\n\n    class Meta:\n        model = Token\n        fields = ['id', 'url', 'display', 'key', 'write_enabled']\n\n\nclass NestedObjectPermissionSerializer(WritableNestedSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:objectpermission-detail')\n    object_types = ContentTypeField(\n        queryset=ContentType.objects.all(),\n        many=True\n    )\n    groups = serializers.SerializerMethodField(read_only=True)\n    users = serializers.SerializerMethodField(read_only=True)\n\n    class Meta:\n        model = ObjectPermission\n        fields = ['id', 'url', 'display', 'name', 'enabled', 'object_types', 'groups', 'users', 'actions']\n\n    def get_groups(self, obj):\n        return [g.name for g in obj.groups.all()]\n\n    def get_users(self, obj):\n        return [u.username for u in obj.users.all()]\n", "path": "netbox/users/api/nested_serializers.py"}, {"content": "from django.contrib.auth.models import Group, User\nfrom django.contrib.contenttypes.models import ContentType\nfrom rest_framework import serializers\n\nfrom netbox.api import ContentTypeField, SerializedPKRelatedField, ValidatedModelSerializer\nfrom users.models import ObjectPermission, Token\nfrom .nested_serializers import *\n\n\n__all__ = (\n    'GroupSerializer',\n    'ObjectPermissionSerializer',\n    'TokenSerializer',\n    'UserSerializer',\n)\n\n\nclass UserSerializer(ValidatedModelSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:user-detail')\n    groups = SerializedPKRelatedField(\n        queryset=Group.objects.all(),\n        serializer=NestedGroupSerializer,\n        required=False,\n        many=True\n    )\n\n    class Meta:\n        model = User\n        fields = (\n            'id', 'url', 'display', 'username', 'password', 'first_name', 'last_name', 'email', 'is_staff', 'is_active',\n            'date_joined', 'groups',\n        )\n        extra_kwargs = {\n            'password': {'write_only': True}\n        }\n\n    def create(self, validated_data):\n        \"\"\"\n        Extract the password from validated data and set it separately to ensure proper hash generation.\n        \"\"\"\n        password = validated_data.pop('password')\n        user = super().create(validated_data)\n        user.set_password(password)\n        user.save()\n\n        return user\n    \n    def get_display(self, obj):\n        if full_name := obj.get_full_name():\n            return f\"{obj.username} ({full_name})\"\n        return obj.username\n\n\nclass GroupSerializer(ValidatedModelSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:group-detail')\n    user_count = serializers.IntegerField(read_only=True)\n\n    class Meta:\n        model = Group\n        fields = ('id', 'url', 'display', 'name', 'user_count')\n\n\nclass TokenSerializer(ValidatedModelSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:token-detail')\n    key = serializers.CharField(min_length=40, max_length=40, allow_blank=True, required=False)\n    user = NestedUserSerializer()\n\n    class Meta:\n        model = Token\n        fields = ('id', 'url', 'display', 'user', 'created', 'expires', 'key', 'write_enabled', 'description')\n\n    def to_internal_value(self, data):\n        if 'key' not in data:\n            data['key'] = Token.generate_key()\n        return super().to_internal_value(data)\n\n\nclass TokenProvisionSerializer(serializers.Serializer):\n    username = serializers.CharField()\n    password = serializers.CharField()\n\n\nclass ObjectPermissionSerializer(ValidatedModelSerializer):\n    url = serializers.HyperlinkedIdentityField(view_name='users-api:objectpermission-detail')\n    object_types = ContentTypeField(\n        queryset=ContentType.objects.all(),\n        many=True\n    )\n    groups = SerializedPKRelatedField(\n        queryset=Group.objects.all(),\n        serializer=NestedGroupSerializer,\n        required=False,\n        many=True\n    )\n    users = SerializedPKRelatedField(\n        queryset=User.objects.all(),\n        serializer=NestedUserSerializer,\n        required=False,\n        many=True\n    )\n\n    class Meta:\n        model = ObjectPermission\n        fields = (\n            'id', 'url', 'display', 'name', 'description', 'enabled', 'object_types', 'groups', 'users', 'actions',\n            'constraints',\n        )\n", "path": "netbox/users/api/serializers.py"}]}