prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Tags over 100 characters
  Found a bug? Please fill out the sections below. 👍
  
  ### Issue Summary
  
  When adding a tag while using the ClusterTaggableManager class, if the tag name is greater than the character limit for the database column no validation error is given.
  
  ### Steps to Reproduce
  
  1. login to admin and edit a page with a tag content panel
  2. create a tag with more than 100 characters
  3. save, or publish the page 
  
  ### Technical details
  
  * Python version: Python 3.5.1
  * Django version: 1.11.13
  * Wagtail version: 1.13.1
  Tags over 100 characters
  Found a bug? Please fill out the sections below. 👍
  
  ### Issue Summary
  
  When adding a tag while using the ClusterTaggableManager class, if the tag name is greater than the character limit for the database column no validation error is given.
  
  ### Steps to Reproduce
  
  1. login to admin and edit a page with a tag content panel
  2. create a tag with more than 100 characters
  3. save, or publish the page 
  
  ### Technical details
  
  * Python version: Python 3.5.1
  * Django version: 1.11.13
  * Wagtail version: 1.13.1
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `wagtail/admin/forms/tags.py`
  Content:
  ```
  1 from taggit.forms import TagField as TaggitTagField
  2 from taggit.models import Tag
  3 
  4 from wagtail.admin.widgets import AdminTagWidget
  5 
  6 
  7 class TagField(TaggitTagField):
  8     """
  9     Extends taggit's TagField with the option to prevent creating tags that do not already exist
  10     """
  11 
  12     widget = AdminTagWidget
  13 
  14     def __init__(self, *args, **kwargs):
  15         self.tag_model = kwargs.pop("tag_model", None)
  16         self.free_tagging = kwargs.pop("free_tagging", None)
  17 
  18         super().__init__(*args, **kwargs)
  19 
  20         # pass on tag_model and free_tagging kwargs to the widget,
  21         # if (and only if) they have been passed explicitly here.
  22         # Otherwise, set default values for clean() to use
  23         if self.tag_model is None:
  24             self.tag_model = Tag
  25         else:
  26             self.widget.tag_model = self.tag_model
  27 
  28         if self.free_tagging is None:
  29             self.free_tagging = getattr(self.tag_model, "free_tagging", True)
  30         else:
  31             self.widget.free_tagging = self.free_tagging
  32 
  33     def clean(self, value):
  34         value = super().clean(value)
  35 
  36         if not self.free_tagging:
  37             # filter value to just the tags that already exist in tag_model
  38             value = list(
  39                 self.tag_model.objects.filter(name__in=value).values_list(
  40                     "name", flat=True
  41                 )
  42             )
  43 
  44         return value
  45
  ```
  --- 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/wagtail/admin/forms/tags.py b/wagtail/admin/forms/tags.py
  --- a/wagtail/admin/forms/tags.py
  +++ b/wagtail/admin/forms/tags.py
  @@ -1,3 +1,5 @@
  +from django.core.exceptions import ValidationError
  +from django.utils.translation import gettext_lazy as _
   from taggit.forms import TagField as TaggitTagField
   from taggit.models import Tag
   
  @@ -31,8 +33,27 @@
               self.widget.free_tagging = self.free_tagging
   
       def clean(self, value):
  +
           value = super().clean(value)
   
  +        max_tag_length = self.tag_model.name.field.max_length
  +        value_too_long = ""
  +        for val in value:
  +            if len(val) > max_tag_length:
  +                if value_too_long:
  +                    value_too_long += ", "
  +                value_too_long += val
  +        if value_too_long:
  +            raise ValidationError(
  +                _(
  +                    "Tag(s) %(value_too_long)s are over %(max_tag_length)d characters"
  +                    % {
  +                        "value_too_long": value_too_long,
  +                        "max_tag_length": max_tag_length,
  +                    }
  +                )
  +            )
  +
           if not self.free_tagging:
               # filter value to just the tags that already exist in tag_model
               value = list(
  
verification_info: {"golden_diff": "diff --git a/wagtail/admin/forms/tags.py b/wagtail/admin/forms/tags.py\n--- a/wagtail/admin/forms/tags.py\n+++ b/wagtail/admin/forms/tags.py\n@@ -1,3 +1,5 @@\n+from django.core.exceptions import ValidationError\n+from django.utils.translation import gettext_lazy as _\n from taggit.forms import TagField as TaggitTagField\n from taggit.models import Tag\n \n@@ -31,8 +33,27 @@\n             self.widget.free_tagging = self.free_tagging\n \n     def clean(self, value):\n+\n         value = super().clean(value)\n \n+        max_tag_length = self.tag_model.name.field.max_length\n+        value_too_long = \"\"\n+        for val in value:\n+            if len(val) > max_tag_length:\n+                if value_too_long:\n+                    value_too_long += \", \"\n+                value_too_long += val\n+        if value_too_long:\n+            raise ValidationError(\n+                _(\n+                    \"Tag(s) %(value_too_long)s are over %(max_tag_length)d characters\"\n+                    % {\n+                        \"value_too_long\": value_too_long,\n+                        \"max_tag_length\": max_tag_length,\n+                    }\n+                )\n+            )\n+\n         if not self.free_tagging:\n             # filter value to just the tags that already exist in tag_model\n             value = list(\n", "issue": "Tags over 100 characters\nFound a bug? Please fill out the sections below. \ud83d\udc4d\r\n\r\n### Issue Summary\r\n\r\nWhen adding a tag while using the ClusterTaggableManager class, if the tag name is greater than the character limit for the database column no validation error is given.\r\n\r\n### Steps to Reproduce\r\n\r\n1. login to admin and edit a page with a tag content panel\r\n2. create a tag with more than 100 characters\r\n3. save, or publish the page \r\n\r\n### Technical details\r\n\r\n* Python version: Python 3.5.1\r\n* Django version: 1.11.13\r\n* Wagtail version: 1.13.1\nTags over 100 characters\nFound a bug? Please fill out the sections below. \ud83d\udc4d\r\n\r\n### Issue Summary\r\n\r\nWhen adding a tag while using the ClusterTaggableManager class, if the tag name is greater than the character limit for the database column no validation error is given.\r\n\r\n### Steps to Reproduce\r\n\r\n1. login to admin and edit a page with a tag content panel\r\n2. create a tag with more than 100 characters\r\n3. save, or publish the page \r\n\r\n### Technical details\r\n\r\n* Python version: Python 3.5.1\r\n* Django version: 1.11.13\r\n* Wagtail version: 1.13.1\n", "before_files": [{"content": "from taggit.forms import TagField as TaggitTagField\nfrom taggit.models import Tag\n\nfrom wagtail.admin.widgets import AdminTagWidget\n\n\nclass TagField(TaggitTagField):\n    \"\"\"\n    Extends taggit's TagField with the option to prevent creating tags that do not already exist\n    \"\"\"\n\n    widget = AdminTagWidget\n\n    def __init__(self, *args, **kwargs):\n        self.tag_model = kwargs.pop(\"tag_model\", None)\n        self.free_tagging = kwargs.pop(\"free_tagging\", None)\n\n        super().__init__(*args, **kwargs)\n\n        # pass on tag_model and free_tagging kwargs to the widget,\n        # if (and only if) they have been passed explicitly here.\n        # Otherwise, set default values for clean() to use\n        if self.tag_model is None:\n            self.tag_model = Tag\n        else:\n            self.widget.tag_model = self.tag_model\n\n        if self.free_tagging is None:\n            self.free_tagging = getattr(self.tag_model, \"free_tagging\", True)\n        else:\n            self.widget.free_tagging = self.free_tagging\n\n    def clean(self, value):\n        value = super().clean(value)\n\n        if not self.free_tagging:\n            # filter value to just the tags that already exist in tag_model\n            value = list(\n                self.tag_model.objects.filter(name__in=value).values_list(\n                    \"name\", flat=True\n                )\n            )\n\n        return value\n", "path": "wagtail/admin/forms/tags.py"}], "after_files": [{"content": "from django.core.exceptions import ValidationError\nfrom django.utils.translation import gettext_lazy as _\nfrom taggit.forms import TagField as TaggitTagField\nfrom taggit.models import Tag\n\nfrom wagtail.admin.widgets import AdminTagWidget\n\n\nclass TagField(TaggitTagField):\n    \"\"\"\n    Extends taggit's TagField with the option to prevent creating tags that do not already exist\n    \"\"\"\n\n    widget = AdminTagWidget\n\n    def __init__(self, *args, **kwargs):\n        self.tag_model = kwargs.pop(\"tag_model\", None)\n        self.free_tagging = kwargs.pop(\"free_tagging\", None)\n\n        super().__init__(*args, **kwargs)\n\n        # pass on tag_model and free_tagging kwargs to the widget,\n        # if (and only if) they have been passed explicitly here.\n        # Otherwise, set default values for clean() to use\n        if self.tag_model is None:\n            self.tag_model = Tag\n        else:\n            self.widget.tag_model = self.tag_model\n\n        if self.free_tagging is None:\n            self.free_tagging = getattr(self.tag_model, \"free_tagging\", True)\n        else:\n            self.widget.free_tagging = self.free_tagging\n\n    def clean(self, value):\n\n        value = super().clean(value)\n\n        max_tag_length = self.tag_model.name.field.max_length\n        value_too_long = \"\"\n        for val in value:\n            if len(val) > max_tag_length:\n                if value_too_long:\n                    value_too_long += \", \"\n                value_too_long += val\n        if value_too_long:\n            raise ValidationError(\n                _(\n                    \"Tag(s) %(value_too_long)s are over %(max_tag_length)d characters\"\n                    % {\n                        \"value_too_long\": value_too_long,\n                        \"max_tag_length\": max_tag_length,\n                    }\n                )\n            )\n\n        if not self.free_tagging:\n            # filter value to just the tags that already exist in tag_model\n            value = list(\n                self.tag_model.objects.filter(name__in=value).values_list(\n                    \"name\", flat=True\n                )\n            )\n\n        return value\n", "path": "wagtail/admin/forms/tags.py"}]}