We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Transaction admin creates internal server error


--- 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/transaction.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.utils.translation import ugettext_lazy as _
10 
11 from ..fields import ValidXMLCharField
12 
13 from akvo.codelists.models import (Currency, DisbursementChannel,TransactionType, Country, Region,
14                                    RegionVocabulary, Sector, SectorCategory, SectorVocabulary)
15 from akvo.codelists.store.codelists_v201 import (AID_TYPE, CURRENCY, DISBURSEMENT_CHANNEL,
16                                                  FINANCE_TYPE, FLOW_TYPE, TIED_STATUS,
17                                                  TRANSACTION_TYPE, COUNTRY, REGION,
18                                                  REGION_VOCABULARY, SECTOR_VOCABULARY)
19 from akvo.utils import codelist_choices, codelist_value
20 
21 
22 class Transaction(models.Model):
23     project = models.ForeignKey('Project', verbose_name=_(u'project'), related_name='transactions')
24     reference = ValidXMLCharField(
25         _(u'reference'), blank=True, max_length=25,
26         help_text=_(u'Enter a reference for the transaction. (25 characters)')
27     )
28     aid_type = ValidXMLCharField(
29         _(u'aid type'), blank=True, max_length=3, choices=codelist_choices(AID_TYPE)
30     )
31     description = ValidXMLCharField(
32         _(u'description'), max_length=255, blank=True,
33         help_text=_(u'Enter a description for the transaction. (255 characters)')
34     )
35     disbursement_channel = ValidXMLCharField(
36         _(u'disbursement channel'), blank=True, max_length=1,
37         choices=codelist_choices(DISBURSEMENT_CHANNEL)
38     )
39     finance_type = ValidXMLCharField(
40         _(u'finance type'), max_length=3, blank=True, choices=codelist_choices(FINANCE_TYPE)
41     )
42     flow_type = ValidXMLCharField(
43         _(u'flow type'), max_length=2, blank=True, choices=codelist_choices(FLOW_TYPE)
44     )
45     tied_status = ValidXMLCharField(
46         _(u'tied status'), blank=True, max_length=1, choices=codelist_choices(TIED_STATUS)
47     )
48     transaction_date = models.DateField(
49         _(u'transaction date'), blank=True, null=True,
50         help_text=_(u'Enter the financial reporting date that '
51                     u'the transaction was/will be undertaken.')
52     )
53     transaction_type = ValidXMLCharField(
54         _(u'transaction type'), blank=True, max_length=2,
55         choices=codelist_choices(TRANSACTION_TYPE),
56         help_text=_(u'Select the type of transaction from the list.')
57     )
58     value = models.DecimalField(
59         _(u'value'), blank=True, null=True, max_digits=11, decimal_places=2,
60         help_text=_(u'Enter the transaction amount.')
61     )
62     value_date = models.DateField(_(u'value date'), blank=True, null=True)
63     currency = ValidXMLCharField(
64         _(u'currency'), blank=True, max_length=3, choices=codelist_choices(CURRENCY)
65     )
66     provider_organisation = models.ForeignKey(
67         'Organisation', verbose_name=_(u'provider organisation'),
68         related_name='providing_transactions', blank=True, null=True, on_delete=models.SET_NULL
69     )
70     provider_organisation_activity = ValidXMLCharField(
71         _(u'provider organisation activity id'), blank=True, max_length=50
72     )
73     receiver_organisation = models.ForeignKey(
74         'Organisation', verbose_name=_(u'receiver organisation'),
75         related_name='receiving_transactions', blank=True, null=True, on_delete=models.SET_NULL
76     )
77     receiver_organisation_activity = ValidXMLCharField(
78         _(u'receiver organisation activity id'), blank=True, max_length=50
79     )
80     recipient_country = ValidXMLCharField(
81         _(u'recipient country'), blank=True, max_length=2, choices=codelist_choices(COUNTRY)
82     )
83     recipient_region = ValidXMLCharField(
84         _(u'recipient region'), blank=True, max_length=3, choices=codelist_choices(REGION)
85     )
86     recipient_region_vocabulary = ValidXMLCharField(
87         _(u'recipient region vocabulary'), blank=True, max_length=1,
88         choices=codelist_choices(REGION_VOCABULARY)
89     )
90 
91     def __unicode__(self):
92         return self.value
93 
94     def iati_currency(self):
95         return codelist_value(Currency, self, 'currency')
96 
97     def iati_transaction_type(self):
98         return codelist_value(TransactionType, self, 'transaction_type')
99 
100     def iati_disbursement_channel(self):
101         return codelist_value(DisbursementChannel, self, 'disbursement_channel')
102 
103     def iati_recipient_country(self):
104         return codelist_value(Country, self, 'recipient_country')
105 
106     def iati_recipient_region(self):
107         return codelist_value(Region, self, 'recipient_region')
108 
109     def iati_recipient_region_vocabulary(self):
110         return codelist_value(RegionVocabulary, self, 'recipient_region_vocabulary')
111 
112     class Meta:
113         app_label = 'rsr'
114         verbose_name = _(u'transaction')
115         verbose_name_plural = _(u'transactions')
116 
117 
118 class TransactionSector(models.Model):
119     project = models.ForeignKey(
120         'Transaction', verbose_name=_(u'transaction'), related_name='sectors'
121     )
122     code = ValidXMLCharField(_(u'sector'), blank=True, max_length=5)
123     text = ValidXMLCharField(
124         _(u'description'), blank=True, max_length=100, help_text=_(u'(max 100 characters)')
125     )
126     vocabulary = ValidXMLCharField(
127         _(u'vocabulary'), blank=True, max_length=5, choices=codelist_choices(SECTOR_VOCABULARY)
128     )
129 
130     def iati_sector(self):
131         if self.code and (self.vocabulary == '1' or self.vocabulary == 'DAC'):
132             return codelist_value(Sector, self, 'code')
133         elif self.code and (self.vocabulary == '2' or self.vocabulary == 'DAC-3'):
134             return codelist_value(SectorCategory, self, 'code')
135         else:
136             return self.code
137 
138     def iati_vocabulary(self):
139         return codelist_value(SectorVocabulary, self, 'vocabulary')
140 
141     class Meta:
142         app_label = 'rsr'
143         verbose_name = _(u'transaction sector')
144         verbose_name_plural = _(u'transaction sectors')
145         unique_together = ('project', 'vocabulary')
146
```
--- 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/transaction.py b/akvo/rsr/models/transaction.py
--- a/akvo/rsr/models/transaction.py
+++ b/akvo/rsr/models/transaction.py
@@ -89,7 +89,7 @@
     )
 
     def __unicode__(self):
-        return self.value
+        return unicode(self.value)
 
     def iati_currency(self):
         return codelist_value(Currency, self, 'currency')

{"golden_diff": "diff --git a/akvo/rsr/models/transaction.py b/akvo/rsr/models/transaction.py\n--- a/akvo/rsr/models/transaction.py\n+++ b/akvo/rsr/models/transaction.py\n@@ -89,7 +89,7 @@\n     )\n \n     def __unicode__(self):\n-        return self.value\n+        return unicode(self.value)\n \n     def iati_currency(self):\n         return codelist_value(Currency, self, 'currency')\n", "issue": "Transaction admin creates internal server error\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.utils.translation import ugettext_lazy as _\n\nfrom ..fields import ValidXMLCharField\n\nfrom akvo.codelists.models import (Currency, DisbursementChannel,TransactionType, Country, Region,\n                                   RegionVocabulary, Sector, SectorCategory, SectorVocabulary)\nfrom akvo.codelists.store.codelists_v201 import (AID_TYPE, CURRENCY, DISBURSEMENT_CHANNEL,\n                                                 FINANCE_TYPE, FLOW_TYPE, TIED_STATUS,\n                                                 TRANSACTION_TYPE, COUNTRY, REGION,\n                                                 REGION_VOCABULARY, SECTOR_VOCABULARY)\nfrom akvo.utils import codelist_choices, codelist_value\n\n\nclass Transaction(models.Model):\n    project = models.ForeignKey('Project', verbose_name=_(u'project'), related_name='transactions')\n    reference = ValidXMLCharField(\n        _(u'reference'), blank=True, max_length=25,\n        help_text=_(u'Enter a reference for the transaction. (25 characters)')\n    )\n    aid_type = ValidXMLCharField(\n        _(u'aid type'), blank=True, max_length=3, choices=codelist_choices(AID_TYPE)\n    )\n    description = ValidXMLCharField(\n        _(u'description'), max_length=255, blank=True,\n        help_text=_(u'Enter a description for the transaction. (255 characters)')\n    )\n    disbursement_channel = ValidXMLCharField(\n        _(u'disbursement channel'), blank=True, max_length=1,\n        choices=codelist_choices(DISBURSEMENT_CHANNEL)\n    )\n    finance_type = ValidXMLCharField(\n        _(u'finance type'), max_length=3, blank=True, choices=codelist_choices(FINANCE_TYPE)\n    )\n    flow_type = ValidXMLCharField(\n        _(u'flow type'), max_length=2, blank=True, choices=codelist_choices(FLOW_TYPE)\n    )\n    tied_status = ValidXMLCharField(\n        _(u'tied status'), blank=True, max_length=1, choices=codelist_choices(TIED_STATUS)\n    )\n    transaction_date = models.DateField(\n        _(u'transaction date'), blank=True, null=True,\n        help_text=_(u'Enter the financial reporting date that '\n                    u'the transaction was/will be undertaken.')\n    )\n    transaction_type = ValidXMLCharField(\n        _(u'transaction type'), blank=True, max_length=2,\n        choices=codelist_choices(TRANSACTION_TYPE),\n        help_text=_(u'Select the type of transaction from the list.')\n    )\n    value = models.DecimalField(\n        _(u'value'), blank=True, null=True, max_digits=11, decimal_places=2,\n        help_text=_(u'Enter the transaction amount.')\n    )\n    value_date = models.DateField(_(u'value date'), blank=True, null=True)\n    currency = ValidXMLCharField(\n        _(u'currency'), blank=True, max_length=3, choices=codelist_choices(CURRENCY)\n    )\n    provider_organisation = models.ForeignKey(\n        'Organisation', verbose_name=_(u'provider organisation'),\n        related_name='providing_transactions', blank=True, null=True, on_delete=models.SET_NULL\n    )\n    provider_organisation_activity = ValidXMLCharField(\n        _(u'provider organisation activity id'), blank=True, max_length=50\n    )\n    receiver_organisation = models.ForeignKey(\n        'Organisation', verbose_name=_(u'receiver organisation'),\n        related_name='receiving_transactions', blank=True, null=True, on_delete=models.SET_NULL\n    )\n    receiver_organisation_activity = ValidXMLCharField(\n        _(u'receiver organisation activity id'), blank=True, max_length=50\n    )\n    recipient_country = ValidXMLCharField(\n        _(u'recipient country'), blank=True, max_length=2, choices=codelist_choices(COUNTRY)\n    )\n    recipient_region = ValidXMLCharField(\n        _(u'recipient region'), blank=True, max_length=3, choices=codelist_choices(REGION)\n    )\n    recipient_region_vocabulary = ValidXMLCharField(\n        _(u'recipient region vocabulary'), blank=True, max_length=1,\n        choices=codelist_choices(REGION_VOCABULARY)\n    )\n\n    def __unicode__(self):\n        return self.value\n\n    def iati_currency(self):\n        return codelist_value(Currency, self, 'currency')\n\n    def iati_transaction_type(self):\n        return codelist_value(TransactionType, self, 'transaction_type')\n\n    def iati_disbursement_channel(self):\n        return codelist_value(DisbursementChannel, self, 'disbursement_channel')\n\n    def iati_recipient_country(self):\n        return codelist_value(Country, self, 'recipient_country')\n\n    def iati_recipient_region(self):\n        return codelist_value(Region, self, 'recipient_region')\n\n    def iati_recipient_region_vocabulary(self):\n        return codelist_value(RegionVocabulary, self, 'recipient_region_vocabulary')\n\n    class Meta:\n        app_label = 'rsr'\n        verbose_name = _(u'transaction')\n        verbose_name_plural = _(u'transactions')\n\n\nclass TransactionSector(models.Model):\n    project = models.ForeignKey(\n        'Transaction', verbose_name=_(u'transaction'), related_name='sectors'\n    )\n    code = ValidXMLCharField(_(u'sector'), blank=True, max_length=5)\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\n    def iati_sector(self):\n        if self.code and (self.vocabulary == '1' or self.vocabulary == 'DAC'):\n            return codelist_value(Sector, self, 'code')\n        elif self.code and (self.vocabulary == '2' or self.vocabulary == 'DAC-3'):\n            return codelist_value(SectorCategory, self, 'code')\n        else:\n            return self.code\n\n    def iati_vocabulary(self):\n        return codelist_value(SectorVocabulary, self, 'vocabulary')\n\n    class Meta:\n        app_label = 'rsr'\n        verbose_name = _(u'transaction sector')\n        verbose_name_plural = _(u'transaction sectors')\n        unique_together = ('project', 'vocabulary')\n", "path": "akvo/rsr/models/transaction.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.utils.translation import ugettext_lazy as _\n\nfrom ..fields import ValidXMLCharField\n\nfrom akvo.codelists.models import (Currency, DisbursementChannel,TransactionType, Country, Region,\n                                   RegionVocabulary, Sector, SectorCategory, SectorVocabulary)\nfrom akvo.codelists.store.codelists_v201 import (AID_TYPE, CURRENCY, DISBURSEMENT_CHANNEL,\n                                                 FINANCE_TYPE, FLOW_TYPE, TIED_STATUS,\n                                                 TRANSACTION_TYPE, COUNTRY, REGION,\n                                                 REGION_VOCABULARY, SECTOR_VOCABULARY)\nfrom akvo.utils import codelist_choices, codelist_value\n\n\nclass Transaction(models.Model):\n    project = models.ForeignKey('Project', verbose_name=_(u'project'), related_name='transactions')\n    reference = ValidXMLCharField(\n        _(u'reference'), blank=True, max_length=25,\n        help_text=_(u'Enter a reference for the transaction. (25 characters)')\n    )\n    aid_type = ValidXMLCharField(\n        _(u'aid type'), blank=True, max_length=3, choices=codelist_choices(AID_TYPE)\n    )\n    description = ValidXMLCharField(\n        _(u'description'), max_length=255, blank=True,\n        help_text=_(u'Enter a description for the transaction. (255 characters)')\n    )\n    disbursement_channel = ValidXMLCharField(\n        _(u'disbursement channel'), blank=True, max_length=1,\n        choices=codelist_choices(DISBURSEMENT_CHANNEL)\n    )\n    finance_type = ValidXMLCharField(\n        _(u'finance type'), max_length=3, blank=True, choices=codelist_choices(FINANCE_TYPE)\n    )\n    flow_type = ValidXMLCharField(\n        _(u'flow type'), max_length=2, blank=True, choices=codelist_choices(FLOW_TYPE)\n    )\n    tied_status = ValidXMLCharField(\n        _(u'tied status'), blank=True, max_length=1, choices=codelist_choices(TIED_STATUS)\n    )\n    transaction_date = models.DateField(\n        _(u'transaction date'), blank=True, null=True,\n        help_text=_(u'Enter the financial reporting date that '\n                    u'the transaction was/will be undertaken.')\n    )\n    transaction_type = ValidXMLCharField(\n        _(u'transaction type'), blank=True, max_length=2,\n        choices=codelist_choices(TRANSACTION_TYPE),\n        help_text=_(u'Select the type of transaction from the list.')\n    )\n    value = models.DecimalField(\n        _(u'value'), blank=True, null=True, max_digits=11, decimal_places=2,\n        help_text=_(u'Enter the transaction amount.')\n    )\n    value_date = models.DateField(_(u'value date'), blank=True, null=True)\n    currency = ValidXMLCharField(\n        _(u'currency'), blank=True, max_length=3, choices=codelist_choices(CURRENCY)\n    )\n    provider_organisation = models.ForeignKey(\n        'Organisation', verbose_name=_(u'provider organisation'),\n        related_name='providing_transactions', blank=True, null=True, on_delete=models.SET_NULL\n    )\n    provider_organisation_activity = ValidXMLCharField(\n        _(u'provider organisation activity id'), blank=True, max_length=50\n    )\n    receiver_organisation = models.ForeignKey(\n        'Organisation', verbose_name=_(u'receiver organisation'),\n        related_name='receiving_transactions', blank=True, null=True, on_delete=models.SET_NULL\n    )\n    receiver_organisation_activity = ValidXMLCharField(\n        _(u'receiver organisation activity id'), blank=True, max_length=50\n    )\n    recipient_country = ValidXMLCharField(\n        _(u'recipient country'), blank=True, max_length=2, choices=codelist_choices(COUNTRY)\n    )\n    recipient_region = ValidXMLCharField(\n        _(u'recipient region'), blank=True, max_length=3, choices=codelist_choices(REGION)\n    )\n    recipient_region_vocabulary = ValidXMLCharField(\n        _(u'recipient region vocabulary'), blank=True, max_length=1,\n        choices=codelist_choices(REGION_VOCABULARY)\n    )\n\n    def __unicode__(self):\n        return unicode(self.value)\n\n    def iati_currency(self):\n        return codelist_value(Currency, self, 'currency')\n\n    def iati_transaction_type(self):\n        return codelist_value(TransactionType, self, 'transaction_type')\n\n    def iati_disbursement_channel(self):\n        return codelist_value(DisbursementChannel, self, 'disbursement_channel')\n\n    def iati_recipient_country(self):\n        return codelist_value(Country, self, 'recipient_country')\n\n    def iati_recipient_region(self):\n        return codelist_value(Region, self, 'recipient_region')\n\n    def iati_recipient_region_vocabulary(self):\n        return codelist_value(RegionVocabulary, self, 'recipient_region_vocabulary')\n\n    class Meta:\n        app_label = 'rsr'\n        verbose_name = _(u'transaction')\n        verbose_name_plural = _(u'transactions')\n\n\nclass TransactionSector(models.Model):\n    project = models.ForeignKey(\n        'Transaction', verbose_name=_(u'transaction'), related_name='sectors'\n    )\n    code = ValidXMLCharField(_(u'sector'), blank=True, max_length=5)\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\n    def iati_sector(self):\n        if self.code and (self.vocabulary == '1' or self.vocabulary == 'DAC'):\n            return codelist_value(Sector, self, 'code')\n        elif self.code and (self.vocabulary == '2' or self.vocabulary == 'DAC-3'):\n            return codelist_value(SectorCategory, self, 'code')\n        else:\n            return self.code\n\n    def iati_vocabulary(self):\n        return codelist_value(SectorVocabulary, self, 'vocabulary')\n\n    class Meta:\n        app_label = 'rsr'\n        verbose_name = _(u'transaction sector')\n        verbose_name_plural = _(u'transaction sectors')\n        unique_together = ('project', 'vocabulary')\n", "path": "akvo/rsr/models/transaction.py"}]}