We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
EmailAddress case sensitivity
When creating a email address for a user (for gsuite sync) that includes capital letters, the user will be suspended. All input should be lowercased, since that is ehat google is doing.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `lego/apps/email/validators.py`
Content:
```
1 from django.core.exceptions import ValidationError
2 from django.core.validators import EmailValidator, RegexValidator
3 
4 from lego.utils.validators import ReservedNameValidator
5 
6 
7 def validate_email_address(email_address):
8 
9     if email_address.is_assigned():
10         raise ValidationError('The address is already assigned')
11 
12 
13 def validate_email_address_content(email_address):
14     """Make sure we only create valid emails."""
15 
16     regex_validator = RegexValidator(regex=EmailValidator.user_regex)
17     reserved_valdator = ReservedNameValidator()
18 
19     regex_validator(email_address.email)
20     reserved_valdator(email_address.email)
21
```

Path: `lego/apps/email/fields.py`
Content:
```
1 from django.core.exceptions import ObjectDoesNotExist
2 from rest_framework import serializers
3 
4 from lego.apps.email.validators import validate_email_address, validate_email_address_content
5 
6 
7 class EmailAddressField(serializers.PrimaryKeyRelatedField):
8     """
9     Manage the email address as a string.
10     """
11 
12     def __init__(self, **kwargs):
13         validators = kwargs.get('validators')
14         kwargs['validators'] = validators if validators is not None else [validate_email_address]
15         kwargs['validators'].append(validate_email_address_content)
16         super().__init__(**kwargs)
17 
18     def to_internal_value(self, data):
19         """
20         Create email if not exists.
21         """
22         try:
23             email_address, _ = self.get_queryset().get_or_create(pk=data)
24             return email_address
25         except ObjectDoesNotExist:
26             self.fail('does_not_exist', pk_value=data)
27         except (TypeError, ValueError):
28             self.fail('incorrect_type', data_type=type(data).__name__)
29
```
--- 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()

```

diff --git a/lego/apps/email/fields.py b/lego/apps/email/fields.py
--- a/lego/apps/email/fields.py
+++ b/lego/apps/email/fields.py
@@ -20,6 +20,7 @@
         Create email if not exists.
         """
         try:
+            data = data.lower()
             email_address, _ = self.get_queryset().get_or_create(pk=data)
             return email_address
         except ObjectDoesNotExist:
diff --git a/lego/apps/email/validators.py b/lego/apps/email/validators.py
--- a/lego/apps/email/validators.py
+++ b/lego/apps/email/validators.py
@@ -5,6 +5,8 @@
 
 
 def validate_email_address(email_address):
+    if email_address.email != email_address.email.lower():
+        raise ValidationError('Email is not lowercased')
 
     if email_address.is_assigned():
         raise ValidationError('The address is already assigned')

{"golden_diff": "diff --git a/lego/apps/email/fields.py b/lego/apps/email/fields.py\n--- a/lego/apps/email/fields.py\n+++ b/lego/apps/email/fields.py\n@@ -20,6 +20,7 @@\n         Create email if not exists.\n         \"\"\"\n         try:\n+            data = data.lower()\n             email_address, _ = self.get_queryset().get_or_create(pk=data)\n             return email_address\n         except ObjectDoesNotExist:\ndiff --git a/lego/apps/email/validators.py b/lego/apps/email/validators.py\n--- a/lego/apps/email/validators.py\n+++ b/lego/apps/email/validators.py\n@@ -5,6 +5,8 @@\n \n \n def validate_email_address(email_address):\n+    if email_address.email != email_address.email.lower():\n+        raise ValidationError('Email is not lowercased')\n \n     if email_address.is_assigned():\n         raise ValidationError('The address is already assigned')\n", "issue": "EmailAddress case sensitivity\nWhen creating a email address for a user (for gsuite sync) that includes capital letters, the user will be suspended. All input should be lowercased, since that is ehat google is doing.\n", "before_files": [{"content": "from django.core.exceptions import ValidationError\nfrom django.core.validators import EmailValidator, RegexValidator\n\nfrom lego.utils.validators import ReservedNameValidator\n\n\ndef validate_email_address(email_address):\n\n    if email_address.is_assigned():\n        raise ValidationError('The address is already assigned')\n\n\ndef validate_email_address_content(email_address):\n    \"\"\"Make sure we only create valid emails.\"\"\"\n\n    regex_validator = RegexValidator(regex=EmailValidator.user_regex)\n    reserved_valdator = ReservedNameValidator()\n\n    regex_validator(email_address.email)\n    reserved_valdator(email_address.email)\n", "path": "lego/apps/email/validators.py"}, {"content": "from django.core.exceptions import ObjectDoesNotExist\nfrom rest_framework import serializers\n\nfrom lego.apps.email.validators import validate_email_address, validate_email_address_content\n\n\nclass EmailAddressField(serializers.PrimaryKeyRelatedField):\n    \"\"\"\n    Manage the email address as a string.\n    \"\"\"\n\n    def __init__(self, **kwargs):\n        validators = kwargs.get('validators')\n        kwargs['validators'] = validators if validators is not None else [validate_email_address]\n        kwargs['validators'].append(validate_email_address_content)\n        super().__init__(**kwargs)\n\n    def to_internal_value(self, data):\n        \"\"\"\n        Create email if not exists.\n        \"\"\"\n        try:\n            email_address, _ = self.get_queryset().get_or_create(pk=data)\n            return email_address\n        except ObjectDoesNotExist:\n            self.fail('does_not_exist', pk_value=data)\n        except (TypeError, ValueError):\n            self.fail('incorrect_type', data_type=type(data).__name__)\n", "path": "lego/apps/email/fields.py"}], "after_files": [{"content": "from django.core.exceptions import ValidationError\nfrom django.core.validators import EmailValidator, RegexValidator\n\nfrom lego.utils.validators import ReservedNameValidator\n\n\ndef validate_email_address(email_address):\n    if email_address.email != email_address.email.lower():\n        raise ValidationError('Email is not lowercased')\n\n    if email_address.is_assigned():\n        raise ValidationError('The address is already assigned')\n\n\ndef validate_email_address_content(email_address):\n    \"\"\"Make sure we only create valid emails.\"\"\"\n\n    regex_validator = RegexValidator(regex=EmailValidator.user_regex)\n    reserved_valdator = ReservedNameValidator()\n\n    regex_validator(email_address.email)\n    reserved_valdator(email_address.email)\n", "path": "lego/apps/email/validators.py"}, {"content": "from django.core.exceptions import ObjectDoesNotExist\nfrom rest_framework import serializers\n\nfrom lego.apps.email.validators import validate_email_address, validate_email_address_content\n\n\nclass EmailAddressField(serializers.PrimaryKeyRelatedField):\n    \"\"\"\n    Manage the email address as a string.\n    \"\"\"\n\n    def __init__(self, **kwargs):\n        validators = kwargs.get('validators')\n        kwargs['validators'] = validators if validators is not None else [validate_email_address]\n        kwargs['validators'].append(validate_email_address_content)\n        super().__init__(**kwargs)\n\n    def to_internal_value(self, data):\n        \"\"\"\n        Create email if not exists.\n        \"\"\"\n        try:\n            data = data.lower()\n            email_address, _ = self.get_queryset().get_or_create(pk=data)\n            return email_address\n        except ObjectDoesNotExist:\n            self.fail('does_not_exist', pk_value=data)\n        except (TypeError, ValueError):\n            self.fail('incorrect_type', data_type=type(data).__name__)\n", "path": "lego/apps/email/fields.py"}]}