We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AttributeError: 'Event' object has no attribute 'number_regs'
Sentry Issue: [CONCREXIT-HC](https://sentry.io/organizations/thalia/issues/3639420824/?referrer=github_integration)

```
AttributeError: 'Event' object has no attribute 'number_regs'
(11 additional frame(s) were not displayed)
...
  File "rest_framework/serializers.py", line 253, in data
    self._data = self.to_representation(self.instance)
  File "rest_framework/serializers.py", line 522, in to_representation
    ret[field.field_name] = field.to_representation(attribute)
  File "rest_framework/serializers.py", line 522, in to_representation
    ret[field.field_name] = field.to_representation(attribute)
  File "rest_framework/fields.py", line 1838, in to_representation
    return method(value)
  File "events/api/v2/serializers/event.py", line 86, in _num_participants
    participant_count = instance.number_regs
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `website/events/api/v2/serializers/event.py`
Content:
```
1 from rest_framework import serializers
2 
3 from activemembers.api.v2.serializers.member_group import MemberGroupSerializer
4 from announcements.api.v2.serializers import SlideSerializer
5 from documents.api.v2.serializers.document import DocumentSerializer
6 from events import services
7 from events.api.v2.serializers.event_registration import EventRegistrationSerializer
8 from events.models import Event, EventRegistration
9 from payments.api.v2.serializers.payment_amount import PaymentAmountSerializer
10 from thaliawebsite.api.v2.serializers import CleanedHTMLSerializer
11 from thaliawebsite.api.v2.serializers.cleaned_model_serializer import (
12     CleanedModelSerializer,
13 )
14 from utils.snippets import create_google_maps_url
15 
16 
17 class EventSerializer(CleanedModelSerializer):
18     """Serializer for events."""
19 
20     class Meta:
21         model = Event
22         fields = (
23             "pk",
24             "title",
25             "description",
26             "caption",
27             "start",
28             "end",
29             "category",
30             "registration_start",
31             "registration_end",
32             "cancel_deadline",
33             "optional_registrations",
34             "location",
35             "price",
36             "fine",
37             "num_participants",
38             "max_participants",
39             "no_registration_message",
40             "cancel_too_late_message",
41             "has_fields",
42             "food_event",
43             "maps_url",
44             "user_permissions",
45             "user_registration",
46             "organisers",
47             "slide",
48             "documents",
49         )
50 
51     description = CleanedHTMLSerializer()
52     organisers = MemberGroupSerializer(many=True)
53     user_registration = serializers.SerializerMethodField("_user_registration")
54     num_participants = serializers.SerializerMethodField("_num_participants")
55     maps_url = serializers.SerializerMethodField("_maps_url")
56     price = PaymentAmountSerializer()
57     fine = PaymentAmountSerializer()
58     slide = SlideSerializer()
59     documents = DocumentSerializer(many=True)
60     user_permissions = serializers.SerializerMethodField("_user_permissions")
61 
62     def _user_registration(self, instance):
63         try:
64             if self.context["request"].member:
65                 reg = instance.eventregistration_set.get(
66                     member=self.context["request"].member
67                 )
68                 return EventRegistrationSerializer(
69                     reg,
70                     context=self.context,
71                     fields=(
72                         "pk",
73                         "present",
74                         "queue_position",
75                         "is_cancelled",
76                         "is_late_cancellation",
77                         "date",
78                         "payment",
79                     ),
80                 ).data
81         except EventRegistration.DoesNotExist:
82             pass
83         return None
84 
85     def _num_participants(self, instance):
86         participant_count = instance.number_regs
87         if instance.max_participants and participant_count > instance.max_participants:
88             return instance.max_participants
89         return participant_count
90 
91     def _user_permissions(self, instance):
92         member = self.context["request"].member
93         return services.event_permissions(member, instance)
94 
95     def _maps_url(self, instance):
96         return create_google_maps_url(instance.map_location, zoom=13, size="450x250")
97
```
--- 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/website/events/api/v2/serializers/event.py b/website/events/api/v2/serializers/event.py
--- a/website/events/api/v2/serializers/event.py
+++ b/website/events/api/v2/serializers/event.py
@@ -83,10 +83,7 @@
         return None
 
     def _num_participants(self, instance):
-        participant_count = instance.number_regs
-        if instance.max_participants and participant_count > instance.max_participants:
-            return instance.max_participants
-        return participant_count
+        return instance.participants.count()
 
     def _user_permissions(self, instance):
         member = self.context["request"].member

{"golden_diff": "diff --git a/website/events/api/v2/serializers/event.py b/website/events/api/v2/serializers/event.py\n--- a/website/events/api/v2/serializers/event.py\n+++ b/website/events/api/v2/serializers/event.py\n@@ -83,10 +83,7 @@\n         return None\n \n     def _num_participants(self, instance):\n-        participant_count = instance.number_regs\n-        if instance.max_participants and participant_count > instance.max_participants:\n-            return instance.max_participants\n-        return participant_count\n+        return instance.participants.count()\n \n     def _user_permissions(self, instance):\n         member = self.context[\"request\"].member\n", "issue": "AttributeError: 'Event' object has no attribute 'number_regs'\nSentry Issue: [CONCREXIT-HC](https://sentry.io/organizations/thalia/issues/3639420824/?referrer=github_integration)\n\n```\nAttributeError: 'Event' object has no attribute 'number_regs'\n(11 additional frame(s) were not displayed)\n...\n  File \"rest_framework/serializers.py\", line 253, in data\n    self._data = self.to_representation(self.instance)\n  File \"rest_framework/serializers.py\", line 522, in to_representation\n    ret[field.field_name] = field.to_representation(attribute)\n  File \"rest_framework/serializers.py\", line 522, in to_representation\n    ret[field.field_name] = field.to_representation(attribute)\n  File \"rest_framework/fields.py\", line 1838, in to_representation\n    return method(value)\n  File \"events/api/v2/serializers/event.py\", line 86, in _num_participants\n    participant_count = instance.number_regs\n```\n", "before_files": [{"content": "from rest_framework import serializers\n\nfrom activemembers.api.v2.serializers.member_group import MemberGroupSerializer\nfrom announcements.api.v2.serializers import SlideSerializer\nfrom documents.api.v2.serializers.document import DocumentSerializer\nfrom events import services\nfrom events.api.v2.serializers.event_registration import EventRegistrationSerializer\nfrom events.models import Event, EventRegistration\nfrom payments.api.v2.serializers.payment_amount import PaymentAmountSerializer\nfrom thaliawebsite.api.v2.serializers import CleanedHTMLSerializer\nfrom thaliawebsite.api.v2.serializers.cleaned_model_serializer import (\n    CleanedModelSerializer,\n)\nfrom utils.snippets import create_google_maps_url\n\n\nclass EventSerializer(CleanedModelSerializer):\n    \"\"\"Serializer for events.\"\"\"\n\n    class Meta:\n        model = Event\n        fields = (\n            \"pk\",\n            \"title\",\n            \"description\",\n            \"caption\",\n            \"start\",\n            \"end\",\n            \"category\",\n            \"registration_start\",\n            \"registration_end\",\n            \"cancel_deadline\",\n            \"optional_registrations\",\n            \"location\",\n            \"price\",\n            \"fine\",\n            \"num_participants\",\n            \"max_participants\",\n            \"no_registration_message\",\n            \"cancel_too_late_message\",\n            \"has_fields\",\n            \"food_event\",\n            \"maps_url\",\n            \"user_permissions\",\n            \"user_registration\",\n            \"organisers\",\n            \"slide\",\n            \"documents\",\n        )\n\n    description = CleanedHTMLSerializer()\n    organisers = MemberGroupSerializer(many=True)\n    user_registration = serializers.SerializerMethodField(\"_user_registration\")\n    num_participants = serializers.SerializerMethodField(\"_num_participants\")\n    maps_url = serializers.SerializerMethodField(\"_maps_url\")\n    price = PaymentAmountSerializer()\n    fine = PaymentAmountSerializer()\n    slide = SlideSerializer()\n    documents = DocumentSerializer(many=True)\n    user_permissions = serializers.SerializerMethodField(\"_user_permissions\")\n\n    def _user_registration(self, instance):\n        try:\n            if self.context[\"request\"].member:\n                reg = instance.eventregistration_set.get(\n                    member=self.context[\"request\"].member\n                )\n                return EventRegistrationSerializer(\n                    reg,\n                    context=self.context,\n                    fields=(\n                        \"pk\",\n                        \"present\",\n                        \"queue_position\",\n                        \"is_cancelled\",\n                        \"is_late_cancellation\",\n                        \"date\",\n                        \"payment\",\n                    ),\n                ).data\n        except EventRegistration.DoesNotExist:\n            pass\n        return None\n\n    def _num_participants(self, instance):\n        participant_count = instance.number_regs\n        if instance.max_participants and participant_count > instance.max_participants:\n            return instance.max_participants\n        return participant_count\n\n    def _user_permissions(self, instance):\n        member = self.context[\"request\"].member\n        return services.event_permissions(member, instance)\n\n    def _maps_url(self, instance):\n        return create_google_maps_url(instance.map_location, zoom=13, size=\"450x250\")\n", "path": "website/events/api/v2/serializers/event.py"}], "after_files": [{"content": "from rest_framework import serializers\n\nfrom activemembers.api.v2.serializers.member_group import MemberGroupSerializer\nfrom announcements.api.v2.serializers import SlideSerializer\nfrom documents.api.v2.serializers.document import DocumentSerializer\nfrom events import services\nfrom events.api.v2.serializers.event_registration import EventRegistrationSerializer\nfrom events.models import Event, EventRegistration\nfrom payments.api.v2.serializers.payment_amount import PaymentAmountSerializer\nfrom thaliawebsite.api.v2.serializers import CleanedHTMLSerializer\nfrom thaliawebsite.api.v2.serializers.cleaned_model_serializer import (\n    CleanedModelSerializer,\n)\nfrom utils.snippets import create_google_maps_url\n\n\nclass EventSerializer(CleanedModelSerializer):\n    \"\"\"Serializer for events.\"\"\"\n\n    class Meta:\n        model = Event\n        fields = (\n            \"pk\",\n            \"title\",\n            \"description\",\n            \"caption\",\n            \"start\",\n            \"end\",\n            \"category\",\n            \"registration_start\",\n            \"registration_end\",\n            \"cancel_deadline\",\n            \"optional_registrations\",\n            \"location\",\n            \"price\",\n            \"fine\",\n            \"num_participants\",\n            \"max_participants\",\n            \"no_registration_message\",\n            \"cancel_too_late_message\",\n            \"has_fields\",\n            \"food_event\",\n            \"maps_url\",\n            \"user_permissions\",\n            \"user_registration\",\n            \"organisers\",\n            \"slide\",\n            \"documents\",\n        )\n\n    description = CleanedHTMLSerializer()\n    organisers = MemberGroupSerializer(many=True)\n    user_registration = serializers.SerializerMethodField(\"_user_registration\")\n    num_participants = serializers.SerializerMethodField(\"_num_participants\")\n    maps_url = serializers.SerializerMethodField(\"_maps_url\")\n    price = PaymentAmountSerializer()\n    fine = PaymentAmountSerializer()\n    slide = SlideSerializer()\n    documents = DocumentSerializer(many=True)\n    user_permissions = serializers.SerializerMethodField(\"_user_permissions\")\n\n    def _user_registration(self, instance):\n        try:\n            if self.context[\"request\"].member:\n                reg = instance.eventregistration_set.get(\n                    member=self.context[\"request\"].member\n                )\n                return EventRegistrationSerializer(\n                    reg,\n                    context=self.context,\n                    fields=(\n                        \"pk\",\n                        \"present\",\n                        \"queue_position\",\n                        \"is_cancelled\",\n                        \"is_late_cancellation\",\n                        \"date\",\n                        \"payment\",\n                    ),\n                ).data\n        except EventRegistration.DoesNotExist:\n            pass\n        return None\n\n    def _num_participants(self, instance):\n        return instance.participants.count()\n\n    def _user_permissions(self, instance):\n        member = self.context[\"request\"].member\n        return services.event_permissions(member, instance)\n\n    def _maps_url(self, instance):\n        return create_google_maps_url(instance.map_location, zoom=13, size=\"450x250\")\n", "path": "website/events/api/v2/serializers/event.py"}]}