We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Sector vocabulary saved value not updated
## Test plan

GIVEN the project editor
WHEN the sector vocabulary AND sector code are filled in
THEN the 'saved-value' attribute of the vocabulary should be correctly updated


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `akvo/rsr/models/sector.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 
3 # Akvo RSR is covered by the GNU Affero General Public License.
4 # See more details in the license.txt file located at the root folder of the Akvo RSR module.
5 # For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
6 
7 
8 from django.db import models
9 from django.db.models.signals import post_save
10 from django.dispatch import receiver
11 from django.core.validators import MaxValueValidator, MinValueValidator
12 from django.utils.translation import ugettext_lazy as _
13 
14 from ..fields import ValidXMLCharField
15 
16 from akvo.codelists import models as codelist_models
17 from akvo.codelists.store.codelists_v201 import SECTOR_VOCABULARY
18 from akvo.utils import codelist_choices, codelist_value
19 
20 
21 class Sector(models.Model):
22     project = models.ForeignKey('Project', verbose_name=_(u'project'), related_name='sectors')
23     sector_code = ValidXMLCharField(
24         _(u'sector code'), blank=True, max_length=5,
25         help_text=_(u'Enter the sector code of the sectors that the project is working within.<br>'
26                     u'See these lists for the DAC-5 and DAC-3 sector codes:<br>'
27                     u'- <a href="http://iatistandard.org/201/codelists/Sector/" target="_blank">'
28                     u'DAC-5 sector codes</a><br>'
29                     u'- <a href="http://iatistandard.org/201/codelists/SectorCategory/" '
30                     u'target="_blank">DAC-3 sector codes</a>')
31     )
32     text = ValidXMLCharField(
33         _(u'description'), blank=True, max_length=100, help_text=_(u'(max 100 characters)')
34     )
35     vocabulary = ValidXMLCharField(
36         _(u'vocabulary'), blank=True, max_length=5, choices=codelist_choices(SECTOR_VOCABULARY)
37     )
38     percentage = models.DecimalField(
39         _(u'sector percentage'), blank=True, null=True, max_digits=4, decimal_places=1,
40         validators=[MaxValueValidator(100), MinValueValidator(0)],
41         help_text=_(u'You can set the percentage of the project that is relevant for '
42                     u'this sector here.')
43     )
44 
45     def __unicode__(self):
46         if self.sector_code:
47             try:
48                 sector_unicode = self.iati_sector().name.capitalize()
49             except Exception as e:
50                 sector_unicode = u'%s' % _(u'Sector code not found')
51         else:
52             sector_unicode = u'%s' % _(u'No sector code specified')
53 
54         if self.percentage:
55             sector_unicode += u' (%s%%)' % str(self.percentage)
56 
57         return sector_unicode
58 
59 
60     def iati_sector_codes(self):
61         if self.sector_code and (self.vocabulary == '1' or self.vocabulary == 'DAC'):
62             return self.sector_code, codelist_value(codelist_models.Sector, self, 'sector_code')
63         elif self.sector_code and (self.vocabulary == '2' or self.vocabulary == 'DAC-3'):
64             return self.sector_code, codelist_value(codelist_models.SectorCategory,
65                                                     self,
66                                                     'sector_code')
67         else:
68             return self.sector_code, self.sector_code
69 
70     def iati_sector(self):
71         if self.sector_code and (self.vocabulary == '1' or self.vocabulary == 'DAC'):
72             return codelist_value(codelist_models.Sector, self, 'sector_code')
73         elif self.sector_code and (self.vocabulary == '2' or self.vocabulary == 'DAC-3'):
74             return codelist_value(codelist_models.SectorCategory, self, 'sector_code')
75         else:
76             return self.sector_code
77 
78     def iati_vocabulary(self):
79         return codelist_value(codelist_models.SectorVocabulary, self, 'vocabulary')
80 
81     class Meta:
82         app_label = 'rsr'
83         verbose_name = _(u'sector')
84         verbose_name_plural = _(u'sectors')
85 
86 @receiver(post_save, sender=Sector)
87 def update_vocabulary(sender, **kwargs):
88     "Updates the vocabulary if not specified."
89     sector = kwargs['instance']
90     if not sector.vocabulary and sector.sector_code:
91         if len(sector.sector_code) == 3:
92             sector.vocabulary = '2'
93         elif len(sector.sector_code) == 5:
94             sector.vocabulary = '1'
95         sector.save()
96
```
--- 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/akvo/rsr/models/sector.py b/akvo/rsr/models/sector.py
--- a/akvo/rsr/models/sector.py
+++ b/akvo/rsr/models/sector.py
@@ -6,8 +6,6 @@
 
 
 from django.db import models
-from django.db.models.signals import post_save
-from django.dispatch import receiver
 from django.core.validators import MaxValueValidator, MinValueValidator
 from django.utils.translation import ugettext_lazy as _
 
@@ -82,14 +80,3 @@
         app_label = 'rsr'
         verbose_name = _(u'sector')
         verbose_name_plural = _(u'sectors')
-
-@receiver(post_save, sender=Sector)
-def update_vocabulary(sender, **kwargs):
-    "Updates the vocabulary if not specified."
-    sector = kwargs['instance']
-    if not sector.vocabulary and sector.sector_code:
-        if len(sector.sector_code) == 3:
-            sector.vocabulary = '2'
-        elif len(sector.sector_code) == 5:
-            sector.vocabulary = '1'
-        sector.save()

{"golden_diff": "diff --git a/akvo/rsr/models/sector.py b/akvo/rsr/models/sector.py\n--- a/akvo/rsr/models/sector.py\n+++ b/akvo/rsr/models/sector.py\n@@ -6,8 +6,6 @@\n \n \n from django.db import models\n-from django.db.models.signals import post_save\n-from django.dispatch import receiver\n from django.core.validators import MaxValueValidator, MinValueValidator\n from django.utils.translation import ugettext_lazy as _\n \n@@ -82,14 +80,3 @@\n         app_label = 'rsr'\n         verbose_name = _(u'sector')\n         verbose_name_plural = _(u'sectors')\n-\n-@receiver(post_save, sender=Sector)\n-def update_vocabulary(sender, **kwargs):\n-    \"Updates the vocabulary if not specified.\"\n-    sector = kwargs['instance']\n-    if not sector.vocabulary and sector.sector_code:\n-        if len(sector.sector_code) == 3:\n-            sector.vocabulary = '2'\n-        elif len(sector.sector_code) == 5:\n-            sector.vocabulary = '1'\n-        sector.save()\n", "issue": "Sector vocabulary saved value not updated\n## Test plan\n\nGIVEN the project editor\nWHEN the sector vocabulary AND sector code are filled in\nTHEN the 'saved-value' attribute of the vocabulary should be correctly updated\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Akvo RSR is covered by the GNU Affero General Public License.\n# See more details in the license.txt file located at the root folder of the Akvo RSR module.\n# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\n\nfrom django.db import models\nfrom django.db.models.signals import post_save\nfrom django.dispatch import receiver\nfrom django.core.validators import MaxValueValidator, MinValueValidator\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom ..fields import ValidXMLCharField\n\nfrom akvo.codelists import models as codelist_models\nfrom akvo.codelists.store.codelists_v201 import SECTOR_VOCABULARY\nfrom akvo.utils import codelist_choices, codelist_value\n\n\nclass Sector(models.Model):\n    project = models.ForeignKey('Project', verbose_name=_(u'project'), related_name='sectors')\n    sector_code = ValidXMLCharField(\n        _(u'sector code'), blank=True, max_length=5,\n        help_text=_(u'Enter the sector code of the sectors that the project is working within.<br>'\n                    u'See these lists for the DAC-5 and DAC-3 sector codes:<br>'\n                    u'- <a href=\"http://iatistandard.org/201/codelists/Sector/\" target=\"_blank\">'\n                    u'DAC-5 sector codes</a><br>'\n                    u'- <a href=\"http://iatistandard.org/201/codelists/SectorCategory/\" '\n                    u'target=\"_blank\">DAC-3 sector codes</a>')\n    )\n    text = ValidXMLCharField(\n        _(u'description'), blank=True, max_length=100, help_text=_(u'(max 100 characters)')\n    )\n    vocabulary = ValidXMLCharField(\n        _(u'vocabulary'), blank=True, max_length=5, choices=codelist_choices(SECTOR_VOCABULARY)\n    )\n    percentage = models.DecimalField(\n        _(u'sector percentage'), blank=True, null=True, max_digits=4, decimal_places=1,\n        validators=[MaxValueValidator(100), MinValueValidator(0)],\n        help_text=_(u'You can set the percentage of the project that is relevant for '\n                    u'this sector here.')\n    )\n\n    def __unicode__(self):\n        if self.sector_code:\n            try:\n                sector_unicode = self.iati_sector().name.capitalize()\n            except Exception as e:\n                sector_unicode = u'%s' % _(u'Sector code not found')\n        else:\n            sector_unicode = u'%s' % _(u'No sector code specified')\n\n        if self.percentage:\n            sector_unicode += u' (%s%%)' % str(self.percentage)\n\n        return sector_unicode\n\n\n    def iati_sector_codes(self):\n        if self.sector_code and (self.vocabulary == '1' or self.vocabulary == 'DAC'):\n            return self.sector_code, codelist_value(codelist_models.Sector, self, 'sector_code')\n        elif self.sector_code and (self.vocabulary == '2' or self.vocabulary == 'DAC-3'):\n            return self.sector_code, codelist_value(codelist_models.SectorCategory,\n                                                    self,\n                                                    'sector_code')\n        else:\n            return self.sector_code, self.sector_code\n\n    def iati_sector(self):\n        if self.sector_code and (self.vocabulary == '1' or self.vocabulary == 'DAC'):\n            return codelist_value(codelist_models.Sector, self, 'sector_code')\n        elif self.sector_code and (self.vocabulary == '2' or self.vocabulary == 'DAC-3'):\n            return codelist_value(codelist_models.SectorCategory, self, 'sector_code')\n        else:\n            return self.sector_code\n\n    def iati_vocabulary(self):\n        return codelist_value(codelist_models.SectorVocabulary, self, 'vocabulary')\n\n    class Meta:\n        app_label = 'rsr'\n        verbose_name = _(u'sector')\n        verbose_name_plural = _(u'sectors')\n\n@receiver(post_save, sender=Sector)\ndef update_vocabulary(sender, **kwargs):\n    \"Updates the vocabulary if not specified.\"\n    sector = kwargs['instance']\n    if not sector.vocabulary and sector.sector_code:\n        if len(sector.sector_code) == 3:\n            sector.vocabulary = '2'\n        elif len(sector.sector_code) == 5:\n            sector.vocabulary = '1'\n        sector.save()\n", "path": "akvo/rsr/models/sector.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n\n# Akvo RSR is covered by the GNU Affero General Public License.\n# See more details in the license.txt file located at the root folder of the Akvo RSR module.\n# For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.\n\n\nfrom django.db import models\nfrom django.core.validators import MaxValueValidator, MinValueValidator\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom ..fields import ValidXMLCharField\n\nfrom akvo.codelists import models as codelist_models\nfrom akvo.codelists.store.codelists_v201 import SECTOR_VOCABULARY\nfrom akvo.utils import codelist_choices, codelist_value\n\n\nclass Sector(models.Model):\n    project = models.ForeignKey('Project', verbose_name=_(u'project'), related_name='sectors')\n    sector_code = ValidXMLCharField(\n        _(u'sector code'), blank=True, max_length=5,\n        help_text=_(u'Enter the sector code of the sectors that the project is working within.<br>'\n                    u'See these lists for the DAC-5 and DAC-3 sector codes:<br>'\n                    u'- <a href=\"http://iatistandard.org/201/codelists/Sector/\" target=\"_blank\">'\n                    u'DAC-5 sector codes</a><br>'\n                    u'- <a href=\"http://iatistandard.org/201/codelists/SectorCategory/\" '\n                    u'target=\"_blank\">DAC-3 sector codes</a>')\n    )\n    text = ValidXMLCharField(\n        _(u'description'), blank=True, max_length=100, help_text=_(u'(max 100 characters)')\n    )\n    vocabulary = ValidXMLCharField(\n        _(u'vocabulary'), blank=True, max_length=5, choices=codelist_choices(SECTOR_VOCABULARY)\n    )\n    percentage = models.DecimalField(\n        _(u'sector percentage'), blank=True, null=True, max_digits=4, decimal_places=1,\n        validators=[MaxValueValidator(100), MinValueValidator(0)],\n        help_text=_(u'You can set the percentage of the project that is relevant for '\n                    u'this sector here.')\n    )\n\n    def __unicode__(self):\n        if self.sector_code:\n            try:\n                sector_unicode = self.iati_sector().name.capitalize()\n            except Exception as e:\n                sector_unicode = u'%s' % _(u'Sector code not found')\n        else:\n            sector_unicode = u'%s' % _(u'No sector code specified')\n\n        if self.percentage:\n            sector_unicode += u' (%s%%)' % str(self.percentage)\n\n        return sector_unicode\n\n\n    def iati_sector_codes(self):\n        if self.sector_code and (self.vocabulary == '1' or self.vocabulary == 'DAC'):\n            return self.sector_code, codelist_value(codelist_models.Sector, self, 'sector_code')\n        elif self.sector_code and (self.vocabulary == '2' or self.vocabulary == 'DAC-3'):\n            return self.sector_code, codelist_value(codelist_models.SectorCategory,\n                                                    self,\n                                                    'sector_code')\n        else:\n            return self.sector_code, self.sector_code\n\n    def iati_sector(self):\n        if self.sector_code and (self.vocabulary == '1' or self.vocabulary == 'DAC'):\n            return codelist_value(codelist_models.Sector, self, 'sector_code')\n        elif self.sector_code and (self.vocabulary == '2' or self.vocabulary == 'DAC-3'):\n            return codelist_value(codelist_models.SectorCategory, self, 'sector_code')\n        else:\n            return self.sector_code\n\n    def iati_vocabulary(self):\n        return codelist_value(codelist_models.SectorVocabulary, self, 'vocabulary')\n\n    class Meta:\n        app_label = 'rsr'\n        verbose_name = _(u'sector')\n        verbose_name_plural = _(u'sectors')\n", "path": "akvo/rsr/models/sector.py"}]}