prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Adding a new languages forces you to specify special characters
  If you add a new language you are blocked with the UI insisting that you add special characters.
  
  ![screen shot 2017-01-16 at 16 01 52](https://cloud.githubusercontent.com/assets/647438/21990281/17dee6e4-dc06-11e6-910a-4b58c6c45192.png)
  
  The part in red is Afrikaans and say "This field is required"
  
  Not all languages require special characters.
  
  Also the model allows `blank=True`
  
  So somewhere we're blocking.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pootle/apps/pootle_app/forms.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 #
  3 # Copyright (C) Pootle contributors.
  4 #
  5 # This file is a part of the Pootle project. It is distributed under the GPL3
  6 # or later license. See the LICENSE file for a copy of the license and the
  7 # AUTHORS file for copyright and authorship information.
  8 
  9 import re
  10 import urlparse
  11 from collections import OrderedDict
  12 
  13 from django import forms
  14 from django.contrib.auth import get_user_model
  15 
  16 from pootle.i18n.gettext import ugettext_lazy as _
  17 from pootle_language.models import Language
  18 from pootle_project.models import Project
  19 from pootle_store.models import Store
  20 
  21 
  22 LANGCODE_RE = re.compile("^[a-z]{2,}([_-]([a-z]{2,}|[0-9]{3}))*(@[a-z0-9]+)?$",
  23                          re.IGNORECASE)
  24 
  25 
  26 class LanguageForm(forms.ModelForm):
  27 
  28     specialchars = forms.CharField(strip=False)
  29 
  30     class Meta(object):
  31         model = Language
  32         fields = ('id', 'code', 'fullname', 'specialchars', 'nplurals',
  33                   'pluralequation',)
  34 
  35     def clean_code(self):
  36         if (not self.cleaned_data['code'] == 'templates' and
  37             not LANGCODE_RE.match(self.cleaned_data['code'])):
  38             raise forms.ValidationError(
  39                 _('Language code does not follow the ISO convention')
  40             )
  41 
  42         return self.cleaned_data["code"]
  43 
  44     def clean_specialchars(self):
  45         """Ensures inputted characters are unique."""
  46         chars = self.cleaned_data['specialchars']
  47         return u''.join(
  48             OrderedDict((char, None) for char in list(chars)).keys()
  49         )
  50 
  51 
  52 class ProjectForm(forms.ModelForm):
  53 
  54     source_language = forms.ModelChoiceField(label=_('Source Language'),
  55                                              queryset=Language.objects.none())
  56 
  57     class Meta(object):
  58         model = Project
  59         fields = ('id', 'code', 'fullname', 'checkstyle',
  60                   'filetypes', 'treestyle', 'source_language', 'ignoredfiles',
  61                   'report_email', 'screenshot_search_prefix', 'disabled',)
  62 
  63     def __init__(self, *args, **kwargs):
  64         super(ProjectForm, self).__init__(*args, **kwargs)
  65 
  66         queryset = Language.objects.exclude(code='templates')
  67         self.fields['source_language'].queryset = queryset
  68 
  69         self.fields["filetypes"].initial = [
  70             self.fields["filetypes"].queryset.get(name="po")]
  71 
  72         if self.instance.id:
  73             if (self.instance.treestyle != 'auto' and
  74                 self.instance.translationproject_set.count() and
  75                 self.instance.treestyle == self.instance._detect_treestyle()):
  76                 self.fields['treestyle'].required = False
  77 
  78     def clean_filetypes(self):
  79         value = self.cleaned_data.get('filetypes', [])
  80         if not self.instance.pk:
  81             return value
  82         for filetype in self.instance.filetypes.all():
  83             if filetype not in value:
  84                 has_stores = Store.objects.filter(
  85                     translation_project__project=self.instance, filetype=filetype)
  86                 if has_stores.exists():
  87                     raise forms.ValidationError(
  88                         _("You cannot remove a file type from a Project, "
  89                           "if there are Stores of that file type ('%s')"
  90                           % filetype))
  91         return value
  92 
  93     def clean_fullname(self):
  94         return self.cleaned_data['fullname'].strip()
  95 
  96     def clean_treestyle(self):
  97         value = self.cleaned_data.get('treestyle', None)
  98         if not value:
  99             value = self.instance.treestyle
  100         return value
  101 
  102     def clean_code(self):
  103         return self.cleaned_data['code'].strip()
  104 
  105 
  106 class UserForm(forms.ModelForm):
  107 
  108     password = forms.CharField(label=_('Password'), required=False,
  109                                widget=forms.PasswordInput)
  110 
  111     class Meta(object):
  112         model = get_user_model()
  113         fields = ('id', 'username', 'is_active', 'full_name', 'email',
  114                   'is_superuser', 'twitter', 'linkedin', 'website', 'bio')
  115 
  116     def __init__(self, *args, **kwargs):
  117         super(UserForm, self).__init__(*args, **kwargs)
  118 
  119         # Require setting the password for new users
  120         if self.instance.pk is None:
  121             self.fields['password'].required = True
  122 
  123     def save(self, commit=True):
  124         password = self.cleaned_data['password']
  125 
  126         if password != '':
  127             user = super(UserForm, self).save(commit=False)
  128             user.set_password(password)
  129 
  130             if commit:
  131                 user.save()
  132         else:
  133             user = super(UserForm, self).save(commit=commit)
  134 
  135         return user
  136 
  137     def clean_linkedin(self):
  138         url = self.cleaned_data['linkedin']
  139         if url != '':
  140             parsed = urlparse.urlparse(url)
  141             if 'linkedin.com' not in parsed.netloc or parsed.path == '/':
  142                 raise forms.ValidationError(
  143                     _('Please enter a valid LinkedIn user profile URL.')
  144                 )
  145 
  146         return url
  147
  ```
  --- 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/pootle/apps/pootle_app/forms.py b/pootle/apps/pootle_app/forms.py
  --- a/pootle/apps/pootle_app/forms.py
  +++ b/pootle/apps/pootle_app/forms.py
  @@ -25,7 +25,7 @@
   
   class LanguageForm(forms.ModelForm):
   
  -    specialchars = forms.CharField(strip=False)
  +    specialchars = forms.CharField(strip=False, required=False)
   
       class Meta(object):
           model = Language
  
verification_info: {"golden_diff": "diff --git a/pootle/apps/pootle_app/forms.py b/pootle/apps/pootle_app/forms.py\n--- a/pootle/apps/pootle_app/forms.py\n+++ b/pootle/apps/pootle_app/forms.py\n@@ -25,7 +25,7 @@\n \n class LanguageForm(forms.ModelForm):\n \n-    specialchars = forms.CharField(strip=False)\n+    specialchars = forms.CharField(strip=False, required=False)\n \n     class Meta(object):\n         model = Language\n", "issue": "Adding a new languages forces you to specify special characters\nIf you add a new language you are blocked with the UI insisting that you add special characters.\r\n\r\n![screen shot 2017-01-16 at 16 01 52](https://cloud.githubusercontent.com/assets/647438/21990281/17dee6e4-dc06-11e6-910a-4b58c6c45192.png)\r\n\r\nThe part in red is Afrikaans and say \"This field is required\"\r\n\r\nNot all languages require special characters.\r\n\r\nAlso the model allows `blank=True`\r\n\r\nSo somewhere we're blocking.\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nimport re\nimport urlparse\nfrom collections import OrderedDict\n\nfrom django import forms\nfrom django.contrib.auth import get_user_model\n\nfrom pootle.i18n.gettext import ugettext_lazy as _\nfrom pootle_language.models import Language\nfrom pootle_project.models import Project\nfrom pootle_store.models import Store\n\n\nLANGCODE_RE = re.compile(\"^[a-z]{2,}([_-]([a-z]{2,}|[0-9]{3}))*(@[a-z0-9]+)?$\",\n                         re.IGNORECASE)\n\n\nclass LanguageForm(forms.ModelForm):\n\n    specialchars = forms.CharField(strip=False)\n\n    class Meta(object):\n        model = Language\n        fields = ('id', 'code', 'fullname', 'specialchars', 'nplurals',\n                  'pluralequation',)\n\n    def clean_code(self):\n        if (not self.cleaned_data['code'] == 'templates' and\n            not LANGCODE_RE.match(self.cleaned_data['code'])):\n            raise forms.ValidationError(\n                _('Language code does not follow the ISO convention')\n            )\n\n        return self.cleaned_data[\"code\"]\n\n    def clean_specialchars(self):\n        \"\"\"Ensures inputted characters are unique.\"\"\"\n        chars = self.cleaned_data['specialchars']\n        return u''.join(\n            OrderedDict((char, None) for char in list(chars)).keys()\n        )\n\n\nclass ProjectForm(forms.ModelForm):\n\n    source_language = forms.ModelChoiceField(label=_('Source Language'),\n                                             queryset=Language.objects.none())\n\n    class Meta(object):\n        model = Project\n        fields = ('id', 'code', 'fullname', 'checkstyle',\n                  'filetypes', 'treestyle', 'source_language', 'ignoredfiles',\n                  'report_email', 'screenshot_search_prefix', 'disabled',)\n\n    def __init__(self, *args, **kwargs):\n        super(ProjectForm, self).__init__(*args, **kwargs)\n\n        queryset = Language.objects.exclude(code='templates')\n        self.fields['source_language'].queryset = queryset\n\n        self.fields[\"filetypes\"].initial = [\n            self.fields[\"filetypes\"].queryset.get(name=\"po\")]\n\n        if self.instance.id:\n            if (self.instance.treestyle != 'auto' and\n                self.instance.translationproject_set.count() and\n                self.instance.treestyle == self.instance._detect_treestyle()):\n                self.fields['treestyle'].required = False\n\n    def clean_filetypes(self):\n        value = self.cleaned_data.get('filetypes', [])\n        if not self.instance.pk:\n            return value\n        for filetype in self.instance.filetypes.all():\n            if filetype not in value:\n                has_stores = Store.objects.filter(\n                    translation_project__project=self.instance, filetype=filetype)\n                if has_stores.exists():\n                    raise forms.ValidationError(\n                        _(\"You cannot remove a file type from a Project, \"\n                          \"if there are Stores of that file type ('%s')\"\n                          % filetype))\n        return value\n\n    def clean_fullname(self):\n        return self.cleaned_data['fullname'].strip()\n\n    def clean_treestyle(self):\n        value = self.cleaned_data.get('treestyle', None)\n        if not value:\n            value = self.instance.treestyle\n        return value\n\n    def clean_code(self):\n        return self.cleaned_data['code'].strip()\n\n\nclass UserForm(forms.ModelForm):\n\n    password = forms.CharField(label=_('Password'), required=False,\n                               widget=forms.PasswordInput)\n\n    class Meta(object):\n        model = get_user_model()\n        fields = ('id', 'username', 'is_active', 'full_name', 'email',\n                  'is_superuser', 'twitter', 'linkedin', 'website', 'bio')\n\n    def __init__(self, *args, **kwargs):\n        super(UserForm, self).__init__(*args, **kwargs)\n\n        # Require setting the password for new users\n        if self.instance.pk is None:\n            self.fields['password'].required = True\n\n    def save(self, commit=True):\n        password = self.cleaned_data['password']\n\n        if password != '':\n            user = super(UserForm, self).save(commit=False)\n            user.set_password(password)\n\n            if commit:\n                user.save()\n        else:\n            user = super(UserForm, self).save(commit=commit)\n\n        return user\n\n    def clean_linkedin(self):\n        url = self.cleaned_data['linkedin']\n        if url != '':\n            parsed = urlparse.urlparse(url)\n            if 'linkedin.com' not in parsed.netloc or parsed.path == '/':\n                raise forms.ValidationError(\n                    _('Please enter a valid LinkedIn user profile URL.')\n                )\n\n        return url\n", "path": "pootle/apps/pootle_app/forms.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n#\n# Copyright (C) Pootle contributors.\n#\n# This file is a part of the Pootle project. It is distributed under the GPL3\n# or later license. See the LICENSE file for a copy of the license and the\n# AUTHORS file for copyright and authorship information.\n\nimport re\nimport urlparse\nfrom collections import OrderedDict\n\nfrom django import forms\nfrom django.contrib.auth import get_user_model\n\nfrom pootle.i18n.gettext import ugettext_lazy as _\nfrom pootle_language.models import Language\nfrom pootle_project.models import Project\nfrom pootle_store.models import Store\n\n\nLANGCODE_RE = re.compile(\"^[a-z]{2,}([_-]([a-z]{2,}|[0-9]{3}))*(@[a-z0-9]+)?$\",\n                         re.IGNORECASE)\n\n\nclass LanguageForm(forms.ModelForm):\n\n    specialchars = forms.CharField(strip=False, required=False)\n\n    class Meta(object):\n        model = Language\n        fields = ('id', 'code', 'fullname', 'specialchars', 'nplurals',\n                  'pluralequation',)\n\n    def clean_code(self):\n        if (not self.cleaned_data['code'] == 'templates' and\n            not LANGCODE_RE.match(self.cleaned_data['code'])):\n            raise forms.ValidationError(\n                _('Language code does not follow the ISO convention')\n            )\n\n        return self.cleaned_data[\"code\"]\n\n    def clean_specialchars(self):\n        \"\"\"Ensures inputted characters are unique.\"\"\"\n        chars = self.cleaned_data['specialchars']\n        return u''.join(\n            OrderedDict((char, None) for char in list(chars)).keys()\n        )\n\n\nclass ProjectForm(forms.ModelForm):\n\n    source_language = forms.ModelChoiceField(label=_('Source Language'),\n                                             queryset=Language.objects.none())\n\n    class Meta(object):\n        model = Project\n        fields = ('id', 'code', 'fullname', 'checkstyle',\n                  'filetypes', 'treestyle', 'source_language', 'ignoredfiles',\n                  'report_email', 'screenshot_search_prefix', 'disabled',)\n\n    def __init__(self, *args, **kwargs):\n        super(ProjectForm, self).__init__(*args, **kwargs)\n\n        queryset = Language.objects.exclude(code='templates')\n        self.fields['source_language'].queryset = queryset\n\n        self.fields[\"filetypes\"].initial = [\n            self.fields[\"filetypes\"].queryset.get(name=\"po\")]\n\n        if self.instance.id:\n            if (self.instance.treestyle != 'auto' and\n                self.instance.translationproject_set.count() and\n                self.instance.treestyle == self.instance._detect_treestyle()):\n                self.fields['treestyle'].required = False\n\n    def clean_filetypes(self):\n        value = self.cleaned_data.get('filetypes', [])\n        if not self.instance.pk:\n            return value\n        for filetype in self.instance.filetypes.all():\n            if filetype not in value:\n                has_stores = Store.objects.filter(\n                    translation_project__project=self.instance, filetype=filetype)\n                if has_stores.exists():\n                    raise forms.ValidationError(\n                        _(\"You cannot remove a file type from a Project, \"\n                          \"if there are Stores of that file type ('%s')\"\n                          % filetype))\n        return value\n\n    def clean_fullname(self):\n        return self.cleaned_data['fullname'].strip()\n\n    def clean_treestyle(self):\n        value = self.cleaned_data.get('treestyle', None)\n        if not value:\n            value = self.instance.treestyle\n        return value\n\n    def clean_code(self):\n        return self.cleaned_data['code'].strip()\n\n\nclass UserForm(forms.ModelForm):\n\n    password = forms.CharField(label=_('Password'), required=False,\n                               widget=forms.PasswordInput)\n\n    class Meta(object):\n        model = get_user_model()\n        fields = ('id', 'username', 'is_active', 'full_name', 'email',\n                  'is_superuser', 'twitter', 'linkedin', 'website', 'bio')\n\n    def __init__(self, *args, **kwargs):\n        super(UserForm, self).__init__(*args, **kwargs)\n\n        # Require setting the password for new users\n        if self.instance.pk is None:\n            self.fields['password'].required = True\n\n    def save(self, commit=True):\n        password = self.cleaned_data['password']\n\n        if password != '':\n            user = super(UserForm, self).save(commit=False)\n            user.set_password(password)\n\n            if commit:\n                user.save()\n        else:\n            user = super(UserForm, self).save(commit=commit)\n\n        return user\n\n    def clean_linkedin(self):\n        url = self.cleaned_data['linkedin']\n        if url != '':\n            parsed = urlparse.urlparse(url)\n            if 'linkedin.com' not in parsed.netloc or parsed.path == '/':\n                raise forms.ValidationError(\n                    _('Please enter a valid LinkedIn user profile URL.')\n                )\n\n        return url\n", "path": "pootle/apps/pootle_app/forms.py"}]}