We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Can change username with duplicates
<!--
Instructions:
 * Fill out the sections below, replace …'s with information about your issue
 * Use the 'preview' function above this text box to verify formatting before submitting
-->

### Observed behavior
<!--
Description of the behavior that was observed, including screenshots or other references when applicable
-->

I was sure I fixed the issue before. It's now reoccurring as seen below:

![bug](https://user-images.githubusercontent.com/27984604/37702097-70a3bfd4-2d2c-11e8-90fc-89ea907d1b47.gif)

 
![screen shot 2018-03-21 at 5 27 13 pm](https://user-images.githubusercontent.com/27984604/37702338-247c7d3e-2d2d-11e8-8e41-1850fca15945.png)


### Expected behavior
<!--
Description of what behavior was expected but did not occur
-->

Should throw an error that says username already exists

### User-facing consequences
<!--
Implications and real-world consequences for learners, coaches, admins, and other users of the application
-->

Can't login?

### Errors and logs
<!--
Relevant logs from:
 * the command line
 * ~/.kolibri/kolibri.log
 * the browser console

Please wrap errors in triple backticks for clean formatting like this:
```
01:10 info: something happened
01:12 error: something bad happened
```
-->

### Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->


### Context
<!--
Tell us about your environment, including:
 * Kolibri version
 * Operating system
 * Browser
-->

Kolibri version: develop

Same username suggestion while signing-in (case-sensitive feature not accounted for) after the user edits a name using the edit username feature.
### Observed behavior
When the user edits the username from his/her profile and then again tries to login, there can be 2 suggestions of same username based on case-sensitive nature, for eg sahilm, sahilM

### Expected behavior

The username must not be allowed to be the same (as mentioned in #3458) and suggestions must not be case-sensitive nature, for eg sahilm and sahilM cannot exist simultaneously.

### User-facing consequences
It would create confusion in the classroom if the students are shown same username.

### Errors and logs

![screenshot from 2018-04-05 09 28 08](https://user-images.githubusercontent.com/38091824/38346997-16e3d8c2-38b6-11e8-9eaf-06fd2bbe375f.png)

![screenshot from 2018-04-05 09 42 44](https://user-images.githubusercontent.com/38091824/38346963-ef6fbe1e-38b5-11e8-80f6-d91032820fe8.png)


### Steps to reproduce

1. Login as admin and give permission to the users to edit the username.
2. Login as a user and edit the username which is same as existing but has different cases, like abc1, ABC1.
3. Try to sign in as user and look for suggestions which will be same with different cases.

### Context

Kolibri version : kolibri 0.9.0
Operating system : ubuntu 14.04
Browser : Chrome

### Screenshot
![screenshot from 2018-04-05 09 42 44](https://user-images.githubusercontent.com/38091824/38347147-3624cccc-38b7-11e8-8f7b-ae3aa681a31c.png)
![screenshot from 2018-04-05 09 16 21](https://user-images.githubusercontent.com/38091824/38347149-44fe7e6e-38b7-11e8-8e53-303a9a14f914.png)
![screenshot from 2018-04-05 09 22 09](https://user-images.githubusercontent.com/38091824/38347177-81abd1c2-38b7-11e8-9dc5-d0c416c18ee5.png)




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kolibri/auth/serializers.py`
Content:
```
1 from __future__ import absolute_import
2 from __future__ import print_function
3 from __future__ import unicode_literals
4 
5 from django.utils.translation import ugettext_lazy as _
6 from rest_framework import serializers
7 from rest_framework.validators import UniqueTogetherValidator
8 
9 from .models import Classroom
10 from .models import Facility
11 from .models import FacilityDataset
12 from .models import FacilityUser
13 from .models import LearnerGroup
14 from .models import Membership
15 from .models import Role
16 
17 
18 class RoleSerializer(serializers.ModelSerializer):
19     collection_parent = serializers.SerializerMethodField()
20 
21     class Meta:
22         model = Role
23         fields = ('id', 'kind', 'collection', 'user', 'collection_parent',)
24 
25     def get_collection_parent(self, instance):
26         if instance.collection.parent is not None:
27             return instance.collection.parent.id
28         else:
29             return None
30 
31 
32 class FacilityUserSerializer(serializers.ModelSerializer):
33     roles = RoleSerializer(many=True, read_only=True)
34 
35     class Meta:
36         model = FacilityUser
37         extra_kwargs = {'password': {'write_only': True}}
38         fields = ('id', 'username', 'full_name', 'password', 'facility', 'roles', 'is_superuser')
39 
40     def create(self, validated_data):
41         if FacilityUser.objects.filter(username__iexact=validated_data['username']).exists():
42             raise serializers.ValidationError(_('An account with that username already exists'))
43         return super(FacilityUserSerializer, self).create(validated_data)
44 
45 
46 class FacilityUserSignupSerializer(FacilityUserSerializer):
47 
48     def validate_username(self, value):
49         if FacilityUser.objects.filter(username__iexact=value).exists():
50             raise serializers.ValidationError(_('An account with that username already exists'))
51         return value
52 
53 
54 class FacilityUsernameSerializer(serializers.ModelSerializer):
55 
56     class Meta:
57         model = FacilityUser
58         fields = ('username', )
59 
60 
61 class MembershipSerializer(serializers.ModelSerializer):
62 
63     class Meta:
64         model = Membership
65         fields = ('id', 'collection', 'user')
66 
67 
68 class FacilityDatasetSerializer(serializers.ModelSerializer):
69 
70     class Meta:
71         model = FacilityDataset
72         fields = ('id', 'learner_can_edit_username', 'learner_can_edit_name', 'learner_can_edit_password',
73                   'learner_can_sign_up', 'learner_can_delete_account', 'learner_can_login_with_no_password',
74                   'show_download_button_in_learn', 'description', 'location')
75 
76 
77 class FacilitySerializer(serializers.ModelSerializer):
78     dataset = FacilityDatasetSerializer(read_only=True)
79 
80     class Meta:
81         model = Facility
82         extra_kwargs = {'id': {'read_only': True}, 'dataset': {'read_only': True}}
83         fields = ('id', 'name', 'dataset')
84 
85 
86 class PublicFacilitySerializer(serializers.ModelSerializer):
87 
88     class Meta:
89         model = Facility
90         fields = ('dataset', 'name')
91 
92 
93 class ClassroomSerializer(serializers.ModelSerializer):
94     learner_count = serializers.SerializerMethodField()
95     coaches = serializers.SerializerMethodField()
96 
97     def get_learner_count(self, instance):
98         return instance.get_members().count()
99 
100     def get_coaches(self, instance):
101         return FacilityUserSerializer(instance.get_coaches(), many=True).data
102 
103     class Meta:
104         model = Classroom
105         fields = (
106             'id',
107             'name',
108             'parent',
109             'learner_count',
110             'coaches',
111         )
112 
113         validators = [
114             UniqueTogetherValidator(
115                 queryset=Classroom.objects.all(),
116                 fields=('parent', 'name')
117             )
118         ]
119 
120 
121 class LearnerGroupSerializer(serializers.ModelSerializer):
122 
123     user_ids = serializers.SerializerMethodField()
124 
125     def get_user_ids(self, group):
126         return [str(user_id['id']) for user_id in group.get_members().values('id')]
127 
128     class Meta:
129         model = LearnerGroup
130         fields = ('id', 'name', 'parent', 'user_ids')
131 
132         validators = [
133             UniqueTogetherValidator(
134                 queryset=Classroom.objects.all(),
135                 fields=('parent', 'name')
136             )
137         ]
138
```
--- 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/kolibri/auth/serializers.py b/kolibri/auth/serializers.py
--- a/kolibri/auth/serializers.py
+++ b/kolibri/auth/serializers.py
@@ -42,6 +42,11 @@
             raise serializers.ValidationError(_('An account with that username already exists'))
         return super(FacilityUserSerializer, self).create(validated_data)
 
+    def update(self, instance, validated_data):
+        if validated_data.get('username') and FacilityUser.objects.exclude(id__exact=instance.id).filter(username__iexact=validated_data['username']).exists():
+            raise serializers.ValidationError(_('An account with that username already exists'))
+        return super(FacilityUserSerializer, self).update(instance, validated_data)
+
 
 class FacilityUserSignupSerializer(FacilityUserSerializer):

{"golden_diff": "diff --git a/kolibri/auth/serializers.py b/kolibri/auth/serializers.py\n--- a/kolibri/auth/serializers.py\n+++ b/kolibri/auth/serializers.py\n@@ -42,6 +42,11 @@\n             raise serializers.ValidationError(_('An account with that username already exists'))\n         return super(FacilityUserSerializer, self).create(validated_data)\n \n+    def update(self, instance, validated_data):\n+        if validated_data.get('username') and FacilityUser.objects.exclude(id__exact=instance.id).filter(username__iexact=validated_data['username']).exists():\n+            raise serializers.ValidationError(_('An account with that username already exists'))\n+        return super(FacilityUserSerializer, self).update(instance, validated_data)\n+\n \n class FacilityUserSignupSerializer(FacilityUserSerializer):\n", "issue": "Can change username with duplicates\n<!--\r\nInstructions:\r\n * Fill out the sections below, replace \u2026's with information about your issue\r\n * Use the 'preview' function above this text box to verify formatting before submitting\r\n-->\r\n\r\n### Observed behavior\r\n<!--\r\nDescription of the behavior that was observed, including screenshots or other references when applicable\r\n-->\r\n\r\nI was sure I fixed the issue before. It's now reoccurring as seen below:\r\n\r\n![bug](https://user-images.githubusercontent.com/27984604/37702097-70a3bfd4-2d2c-11e8-90fc-89ea907d1b47.gif)\r\n\r\n \r\n![screen shot 2018-03-21 at 5 27 13 pm](https://user-images.githubusercontent.com/27984604/37702338-247c7d3e-2d2d-11e8-8e41-1850fca15945.png)\r\n\r\n\r\n### Expected behavior\r\n<!--\r\nDescription of what behavior was expected but did not occur\r\n-->\r\n\r\nShould throw an error that says username already exists\r\n\r\n### User-facing consequences\r\n<!--\r\nImplications and real-world consequences for learners, coaches, admins, and other users of the application\r\n-->\r\n\r\nCan't login?\r\n\r\n### Errors and logs\r\n<!--\r\nRelevant logs from:\r\n * the command line\r\n * ~/.kolibri/kolibri.log\r\n * the browser console\r\n\r\nPlease wrap errors in triple backticks for clean formatting like this:\r\n```\r\n01:10 info: something happened\r\n01:12 error: something bad happened\r\n```\r\n-->\r\n\r\n### Steps to reproduce\r\n<!--\r\nPrecise steps that someone else can follow in order to see this behavior\r\n-->\r\n\r\n\r\n### Context\r\n<!--\r\nTell us about your environment, including:\r\n * Kolibri version\r\n * Operating system\r\n * Browser\r\n-->\r\n\r\nKolibri version: develop\r\n\nSame username suggestion while signing-in (case-sensitive feature not accounted for) after the user edits a name using the edit username feature.\n### Observed behavior\r\nWhen the user edits the username from his/her profile and then again tries to login, there can be 2 suggestions of same username based on case-sensitive nature, for eg sahilm, sahilM\r\n\r\n### Expected behavior\r\n\r\nThe username must not be allowed to be the same (as mentioned in #3458) and suggestions must not be case-sensitive nature, for eg sahilm and sahilM cannot exist simultaneously.\r\n\r\n### User-facing consequences\r\nIt would create confusion in the classroom if the students are shown same username.\r\n\r\n### Errors and logs\r\n\r\n![screenshot from 2018-04-05 09 28 08](https://user-images.githubusercontent.com/38091824/38346997-16e3d8c2-38b6-11e8-9eaf-06fd2bbe375f.png)\r\n\r\n![screenshot from 2018-04-05 09 42 44](https://user-images.githubusercontent.com/38091824/38346963-ef6fbe1e-38b5-11e8-80f6-d91032820fe8.png)\r\n\r\n\r\n### Steps to reproduce\r\n\r\n1. Login as admin and give permission to the users to edit the username.\r\n2. Login as a user and edit the username which is same as existing but has different cases, like abc1, ABC1.\r\n3. Try to sign in as user and look for suggestions which will be same with different cases.\r\n\r\n### Context\r\n\r\nKolibri version : kolibri 0.9.0\r\nOperating system : ubuntu 14.04\r\nBrowser : Chrome\r\n\r\n### Screenshot\r\n![screenshot from 2018-04-05 09 42 44](https://user-images.githubusercontent.com/38091824/38347147-3624cccc-38b7-11e8-8f7b-ae3aa681a31c.png)\r\n![screenshot from 2018-04-05 09 16 21](https://user-images.githubusercontent.com/38091824/38347149-44fe7e6e-38b7-11e8-8e53-303a9a14f914.png)\r\n![screenshot from 2018-04-05 09 22 09](https://user-images.githubusercontent.com/38091824/38347177-81abd1c2-38b7-11e8-9dc5-d0c416c18ee5.png)\r\n\r\n\r\n\n", "before_files": [{"content": "from __future__ import absolute_import\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\nfrom django.utils.translation import ugettext_lazy as _\nfrom rest_framework import serializers\nfrom rest_framework.validators import UniqueTogetherValidator\n\nfrom .models import Classroom\nfrom .models import Facility\nfrom .models import FacilityDataset\nfrom .models import FacilityUser\nfrom .models import LearnerGroup\nfrom .models import Membership\nfrom .models import Role\n\n\nclass RoleSerializer(serializers.ModelSerializer):\n    collection_parent = serializers.SerializerMethodField()\n\n    class Meta:\n        model = Role\n        fields = ('id', 'kind', 'collection', 'user', 'collection_parent',)\n\n    def get_collection_parent(self, instance):\n        if instance.collection.parent is not None:\n            return instance.collection.parent.id\n        else:\n            return None\n\n\nclass FacilityUserSerializer(serializers.ModelSerializer):\n    roles = RoleSerializer(many=True, read_only=True)\n\n    class Meta:\n        model = FacilityUser\n        extra_kwargs = {'password': {'write_only': True}}\n        fields = ('id', 'username', 'full_name', 'password', 'facility', 'roles', 'is_superuser')\n\n    def create(self, validated_data):\n        if FacilityUser.objects.filter(username__iexact=validated_data['username']).exists():\n            raise serializers.ValidationError(_('An account with that username already exists'))\n        return super(FacilityUserSerializer, self).create(validated_data)\n\n\nclass FacilityUserSignupSerializer(FacilityUserSerializer):\n\n    def validate_username(self, value):\n        if FacilityUser.objects.filter(username__iexact=value).exists():\n            raise serializers.ValidationError(_('An account with that username already exists'))\n        return value\n\n\nclass FacilityUsernameSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = FacilityUser\n        fields = ('username', )\n\n\nclass MembershipSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Membership\n        fields = ('id', 'collection', 'user')\n\n\nclass FacilityDatasetSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = FacilityDataset\n        fields = ('id', 'learner_can_edit_username', 'learner_can_edit_name', 'learner_can_edit_password',\n                  'learner_can_sign_up', 'learner_can_delete_account', 'learner_can_login_with_no_password',\n                  'show_download_button_in_learn', 'description', 'location')\n\n\nclass FacilitySerializer(serializers.ModelSerializer):\n    dataset = FacilityDatasetSerializer(read_only=True)\n\n    class Meta:\n        model = Facility\n        extra_kwargs = {'id': {'read_only': True}, 'dataset': {'read_only': True}}\n        fields = ('id', 'name', 'dataset')\n\n\nclass PublicFacilitySerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Facility\n        fields = ('dataset', 'name')\n\n\nclass ClassroomSerializer(serializers.ModelSerializer):\n    learner_count = serializers.SerializerMethodField()\n    coaches = serializers.SerializerMethodField()\n\n    def get_learner_count(self, instance):\n        return instance.get_members().count()\n\n    def get_coaches(self, instance):\n        return FacilityUserSerializer(instance.get_coaches(), many=True).data\n\n    class Meta:\n        model = Classroom\n        fields = (\n            'id',\n            'name',\n            'parent',\n            'learner_count',\n            'coaches',\n        )\n\n        validators = [\n            UniqueTogetherValidator(\n                queryset=Classroom.objects.all(),\n                fields=('parent', 'name')\n            )\n        ]\n\n\nclass LearnerGroupSerializer(serializers.ModelSerializer):\n\n    user_ids = serializers.SerializerMethodField()\n\n    def get_user_ids(self, group):\n        return [str(user_id['id']) for user_id in group.get_members().values('id')]\n\n    class Meta:\n        model = LearnerGroup\n        fields = ('id', 'name', 'parent', 'user_ids')\n\n        validators = [\n            UniqueTogetherValidator(\n                queryset=Classroom.objects.all(),\n                fields=('parent', 'name')\n            )\n        ]\n", "path": "kolibri/auth/serializers.py"}], "after_files": [{"content": "from __future__ import absolute_import\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\nfrom django.utils.translation import ugettext_lazy as _\nfrom rest_framework import serializers\nfrom rest_framework.validators import UniqueTogetherValidator\n\nfrom .models import Classroom\nfrom .models import Facility\nfrom .models import FacilityDataset\nfrom .models import FacilityUser\nfrom .models import LearnerGroup\nfrom .models import Membership\nfrom .models import Role\n\n\nclass RoleSerializer(serializers.ModelSerializer):\n    collection_parent = serializers.SerializerMethodField()\n\n    class Meta:\n        model = Role\n        fields = ('id', 'kind', 'collection', 'user', 'collection_parent',)\n\n    def get_collection_parent(self, instance):\n        if instance.collection.parent is not None:\n            return instance.collection.parent.id\n        else:\n            return None\n\n\nclass FacilityUserSerializer(serializers.ModelSerializer):\n    roles = RoleSerializer(many=True, read_only=True)\n\n    class Meta:\n        model = FacilityUser\n        extra_kwargs = {'password': {'write_only': True}}\n        fields = ('id', 'username', 'full_name', 'password', 'facility', 'roles', 'is_superuser')\n\n    def create(self, validated_data):\n        if FacilityUser.objects.filter(username__iexact=validated_data['username']).exists():\n            raise serializers.ValidationError(_('An account with that username already exists'))\n        return super(FacilityUserSerializer, self).create(validated_data)\n\n    def update(self, instance, validated_data):\n        if validated_data.get('username') and FacilityUser.objects.exclude(id__exact=instance.id).filter(username__iexact=validated_data['username']).exists():\n            raise serializers.ValidationError(_('An account with that username already exists'))\n        return super(FacilityUserSerializer, self).update(instance, validated_data)\n\n\nclass FacilityUserSignupSerializer(FacilityUserSerializer):\n\n    def validate_username(self, value):\n        if FacilityUser.objects.filter(username__iexact=value).exists():\n            raise serializers.ValidationError(_('An account with that username already exists'))\n        return value\n\n\nclass FacilityUsernameSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = FacilityUser\n        fields = ('username', )\n\n\nclass MembershipSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Membership\n        fields = ('id', 'collection', 'user')\n\n\nclass FacilityDatasetSerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = FacilityDataset\n        fields = ('id', 'learner_can_edit_username', 'learner_can_edit_name', 'learner_can_edit_password',\n                  'learner_can_sign_up', 'learner_can_delete_account', 'learner_can_login_with_no_password',\n                  'show_download_button_in_learn', 'description', 'location')\n\n\nclass FacilitySerializer(serializers.ModelSerializer):\n    dataset = FacilityDatasetSerializer(read_only=True)\n\n    class Meta:\n        model = Facility\n        extra_kwargs = {'id': {'read_only': True}, 'dataset': {'read_only': True}}\n        fields = ('id', 'name', 'dataset')\n\n\nclass PublicFacilitySerializer(serializers.ModelSerializer):\n\n    class Meta:\n        model = Facility\n        fields = ('dataset', 'name')\n\n\nclass ClassroomSerializer(serializers.ModelSerializer):\n    learner_count = serializers.SerializerMethodField()\n    coaches = serializers.SerializerMethodField()\n\n    def get_learner_count(self, instance):\n        return instance.get_members().count()\n\n    def get_coaches(self, instance):\n        return FacilityUserSerializer(instance.get_coaches(), many=True).data\n\n    class Meta:\n        model = Classroom\n        fields = (\n            'id',\n            'name',\n            'parent',\n            'learner_count',\n            'coaches',\n        )\n\n        validators = [\n            UniqueTogetherValidator(\n                queryset=Classroom.objects.all(),\n                fields=('parent', 'name')\n            )\n        ]\n\n\nclass LearnerGroupSerializer(serializers.ModelSerializer):\n\n    user_ids = serializers.SerializerMethodField()\n\n    def get_user_ids(self, group):\n        return [str(user_id['id']) for user_id in group.get_members().values('id')]\n\n    class Meta:\n        model = LearnerGroup\n        fields = ('id', 'name', 'parent', 'user_ids')\n\n        validators = [\n            UniqueTogetherValidator(\n                queryset=Classroom.objects.all(),\n                fields=('parent', 'name')\n            )\n        ]\n", "path": "kolibri/auth/serializers.py"}]}