prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  FieldError: Cannot resolve keyword 'pizza_event' into field. Choices are: food_event, food_event_id, id, memb...
  Sentry Issue: [CONCREXIT-6G](https://sentry.io/organizations/thalia/issues/2468308255/?referrer=github_integration)
  
  ```
  FieldError: Cannot resolve keyword 'pizza_event' into field. Choices are: food_event, food_event_id, id, member, member_id, name, payment, payment_id, product, product_id
  (9 additional frame(s) were not displayed)
  ...
    File "django/db/models/sql/query.py", line 1391, in add_q
      clause, _ = self._add_q(q_object, self.used_aliases)
    File "django/db/models/sql/query.py", line 1410, in _add_q
      child_clause, needed_inner = self.build_filter(
    File "django/db/models/sql/query.py", line 1284, in build_filter
      lookups, parts, reffed_expression = self.solve_lookup_type(arg)
    File "django/db/models/sql/query.py", line 1110, in solve_lookup_type
      _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
    File "django/db/models/sql/query.py", line 1537, in names_to_path
      raise FieldError("Cannot resolve keyword '%s' into field. "
  ```
  
  --- 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/pizzas/services.py`
  Content:
  ```
  1 from events.services import is_organiser
  2 from .models import Product, FoodOrder, FoodEvent
  3 
  4 
  5 def gen_stats_pizza_orders():
  6     """Generate statistics about number of orders per product.
  7 
  8     :return: Dict with key, value being resp. name, order count of a product.
  9     """
  10     total = {}
  11 
  12     for product in Product.objects.all():
  13         total.update(
  14             {product.name: FoodOrder.objects.filter(product=product).count(),}
  15         )
  16 
  17     return {
  18         i[0]: i[1]
  19         for i in sorted(total.items(), key=lambda x: x[1], reverse=True)[:5]
  20         if i[1] > 0
  21     }
  22 
  23 
  24 def gen_stats_current_pizza_orders():
  25     """Generate statistics about number of orders per product of the active pizza event.
  26 
  27     :return: Dict with key, value being resp. name, order count of a product.
  28     """
  29     total = {}
  30 
  31     current_pizza_event = FoodEvent.current()
  32     if not current_pizza_event:
  33         return None
  34 
  35     for product in Product.objects.filter():
  36         total.update(
  37             {
  38                 product.name: FoodOrder.objects.filter(
  39                     product=product, pizza_event=current_pizza_event,
  40                 ).count(),
  41             }
  42         )
  43 
  44     return {
  45         i[0]: i[1]
  46         for i in sorted(total.items(), key=lambda x: x[1], reverse=True)[:5]
  47         if i[1] > 0
  48     }
  49 
  50 
  51 def can_change_order(member, food_event):
  52     """Determine if a certain member can edit orders of an event.
  53 
  54     :param member: Member who wants to change and order
  55     :param food_event: The event for which we want to change an order
  56     :return: True if we can change an order else False
  57     """
  58     return (
  59         food_event
  60         and member.has_perm("pizzas.change_foodorder")
  61         and is_organiser(member, food_event.event)
  62     )
  63
  ```
  
  Path: `website/pizzas/views.py`
  Content:
  ```
  1 """Views provided by the pizzas package."""
  2 from django.contrib import messages
  3 from django.contrib.auth.decorators import login_required
  4 from django.http import Http404
  5 from django.shortcuts import get_object_or_404, render, redirect
  6 from django.utils.translation import gettext_lazy as _
  7 from django.views.decorators.http import require_http_methods
  8 
  9 from .models import FoodOrder, FoodEvent, Product
  10 
  11 
  12 @login_required
  13 def index(request):
  14     """Overview of user order for a pizza event."""
  15     products = Product.available_products.order_by("name")
  16     if not request.user.has_perm("pizzas.order_restricted_products"):
  17         products = products.exclude(restricted=True)
  18     event = FoodEvent.current()
  19     try:
  20         obj = FoodOrder.objects.get(pizza_event=event, member=request.member)
  21     except FoodOrder.DoesNotExist:
  22         obj = None
  23     context = {"event": event, "products": products, "order": obj}
  24     return render(request, "pizzas/index.html", context)
  25 
  26 
  27 @require_http_methods(["POST"])
  28 def cancel_order(request):
  29     """View that cancels a user's order."""
  30     if "order" in request.POST:
  31         try:
  32             order = get_object_or_404(FoodOrder, pk=int(request.POST["order"]))
  33             if not order.can_be_changed:
  34                 messages.error(request, _("You can no longer cancel."))
  35             elif order.member == request.member:
  36                 order.delete()
  37                 messages.success(request, _("Your order has been cancelled."))
  38         except Http404:
  39             messages.error(request, _("Your order could not be found."))
  40     return redirect("pizzas:index")
  41 
  42 
  43 @login_required
  44 def place_order(request):
  45     """View that shows the detail of the current order."""
  46     event = FoodEvent.current()
  47     if not event:
  48         return redirect("pizzas:index")
  49 
  50     try:
  51         obj = FoodOrder.objects.get(pizza_event=event, member=request.member)
  52         current_order_locked = not obj.can_be_changed
  53     except FoodOrder.DoesNotExist:
  54         obj = None
  55         current_order_locked = False
  56 
  57     if "product" in request.POST and not current_order_locked:
  58         productset = Product.available_products.all()
  59         if not request.user.has_perm("pizzas.order_restricted_products"):
  60             productset = productset.exclude(restricted=True)
  61         try:
  62             product = productset.get(pk=int(request.POST["product"]))
  63         except Product.DoesNotExist as e:
  64             raise Http404("Pizza does not exist") from e
  65         if not obj:
  66             obj = FoodOrder(pizza_event=event, member=request.member)
  67         obj.product = product
  68         obj.save()
  69     return redirect("pizzas:index")
  70
  ```
  --- 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/website/pizzas/services.py b/website/pizzas/services.py
  --- a/website/pizzas/services.py
  +++ b/website/pizzas/services.py
  @@ -36,7 +36,7 @@
           total.update(
               {
                   product.name: FoodOrder.objects.filter(
  -                    product=product, pizza_event=current_pizza_event,
  +                    product=product, food_event=current_pizza_event,
                   ).count(),
               }
           )
  diff --git a/website/pizzas/views.py b/website/pizzas/views.py
  --- a/website/pizzas/views.py
  +++ b/website/pizzas/views.py
  @@ -17,7 +17,7 @@
           products = products.exclude(restricted=True)
       event = FoodEvent.current()
       try:
  -        obj = FoodOrder.objects.get(pizza_event=event, member=request.member)
  +        obj = FoodOrder.objects.get(food_event=event, member=request.member)
       except FoodOrder.DoesNotExist:
           obj = None
       context = {"event": event, "products": products, "order": obj}
  @@ -48,7 +48,7 @@
           return redirect("pizzas:index")
   
       try:
  -        obj = FoodOrder.objects.get(pizza_event=event, member=request.member)
  +        obj = FoodOrder.objects.get(food_event=event, member=request.member)
           current_order_locked = not obj.can_be_changed
       except FoodOrder.DoesNotExist:
           obj = None
  @@ -63,7 +63,7 @@
           except Product.DoesNotExist as e:
               raise Http404("Pizza does not exist") from e
           if not obj:
  -            obj = FoodOrder(pizza_event=event, member=request.member)
  +            obj = FoodOrder(food_event=event, member=request.member)
           obj.product = product
           obj.save()
       return redirect("pizzas:index")
  
verification_info: {"golden_diff": "diff --git a/website/pizzas/services.py b/website/pizzas/services.py\n--- a/website/pizzas/services.py\n+++ b/website/pizzas/services.py\n@@ -36,7 +36,7 @@\n         total.update(\n             {\n                 product.name: FoodOrder.objects.filter(\n-                    product=product, pizza_event=current_pizza_event,\n+                    product=product, food_event=current_pizza_event,\n                 ).count(),\n             }\n         )\ndiff --git a/website/pizzas/views.py b/website/pizzas/views.py\n--- a/website/pizzas/views.py\n+++ b/website/pizzas/views.py\n@@ -17,7 +17,7 @@\n         products = products.exclude(restricted=True)\n     event = FoodEvent.current()\n     try:\n-        obj = FoodOrder.objects.get(pizza_event=event, member=request.member)\n+        obj = FoodOrder.objects.get(food_event=event, member=request.member)\n     except FoodOrder.DoesNotExist:\n         obj = None\n     context = {\"event\": event, \"products\": products, \"order\": obj}\n@@ -48,7 +48,7 @@\n         return redirect(\"pizzas:index\")\n \n     try:\n-        obj = FoodOrder.objects.get(pizza_event=event, member=request.member)\n+        obj = FoodOrder.objects.get(food_event=event, member=request.member)\n         current_order_locked = not obj.can_be_changed\n     except FoodOrder.DoesNotExist:\n         obj = None\n@@ -63,7 +63,7 @@\n         except Product.DoesNotExist as e:\n             raise Http404(\"Pizza does not exist\") from e\n         if not obj:\n-            obj = FoodOrder(pizza_event=event, member=request.member)\n+            obj = FoodOrder(food_event=event, member=request.member)\n         obj.product = product\n         obj.save()\n     return redirect(\"pizzas:index\")\n", "issue": "FieldError: Cannot resolve keyword 'pizza_event' into field. Choices are: food_event, food_event_id, id, memb...\nSentry Issue: [CONCREXIT-6G](https://sentry.io/organizations/thalia/issues/2468308255/?referrer=github_integration)\n\n```\nFieldError: Cannot resolve keyword 'pizza_event' into field. Choices are: food_event, food_event_id, id, member, member_id, name, payment, payment_id, product, product_id\n(9 additional frame(s) were not displayed)\n...\n  File \"django/db/models/sql/query.py\", line 1391, in add_q\n    clause, _ = self._add_q(q_object, self.used_aliases)\n  File \"django/db/models/sql/query.py\", line 1410, in _add_q\n    child_clause, needed_inner = self.build_filter(\n  File \"django/db/models/sql/query.py\", line 1284, in build_filter\n    lookups, parts, reffed_expression = self.solve_lookup_type(arg)\n  File \"django/db/models/sql/query.py\", line 1110, in solve_lookup_type\n    _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())\n  File \"django/db/models/sql/query.py\", line 1537, in names_to_path\n    raise FieldError(\"Cannot resolve keyword '%s' into field. \"\n```\n", "before_files": [{"content": "from events.services import is_organiser\nfrom .models import Product, FoodOrder, FoodEvent\n\n\ndef gen_stats_pizza_orders():\n    \"\"\"Generate statistics about number of orders per product.\n\n    :return: Dict with key, value being resp. name, order count of a product.\n    \"\"\"\n    total = {}\n\n    for product in Product.objects.all():\n        total.update(\n            {product.name: FoodOrder.objects.filter(product=product).count(),}\n        )\n\n    return {\n        i[0]: i[1]\n        for i in sorted(total.items(), key=lambda x: x[1], reverse=True)[:5]\n        if i[1] > 0\n    }\n\n\ndef gen_stats_current_pizza_orders():\n    \"\"\"Generate statistics about number of orders per product of the active pizza event.\n\n    :return: Dict with key, value being resp. name, order count of a product.\n    \"\"\"\n    total = {}\n\n    current_pizza_event = FoodEvent.current()\n    if not current_pizza_event:\n        return None\n\n    for product in Product.objects.filter():\n        total.update(\n            {\n                product.name: FoodOrder.objects.filter(\n                    product=product, pizza_event=current_pizza_event,\n                ).count(),\n            }\n        )\n\n    return {\n        i[0]: i[1]\n        for i in sorted(total.items(), key=lambda x: x[1], reverse=True)[:5]\n        if i[1] > 0\n    }\n\n\ndef can_change_order(member, food_event):\n    \"\"\"Determine if a certain member can edit orders of an event.\n\n    :param member: Member who wants to change and order\n    :param food_event: The event for which we want to change an order\n    :return: True if we can change an order else False\n    \"\"\"\n    return (\n        food_event\n        and member.has_perm(\"pizzas.change_foodorder\")\n        and is_organiser(member, food_event.event)\n    )\n", "path": "website/pizzas/services.py"}, {"content": "\"\"\"Views provided by the pizzas package.\"\"\"\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.http import Http404\nfrom django.shortcuts import get_object_or_404, render, redirect\nfrom django.utils.translation import gettext_lazy as _\nfrom django.views.decorators.http import require_http_methods\n\nfrom .models import FoodOrder, FoodEvent, Product\n\n\n@login_required\ndef index(request):\n    \"\"\"Overview of user order for a pizza event.\"\"\"\n    products = Product.available_products.order_by(\"name\")\n    if not request.user.has_perm(\"pizzas.order_restricted_products\"):\n        products = products.exclude(restricted=True)\n    event = FoodEvent.current()\n    try:\n        obj = FoodOrder.objects.get(pizza_event=event, member=request.member)\n    except FoodOrder.DoesNotExist:\n        obj = None\n    context = {\"event\": event, \"products\": products, \"order\": obj}\n    return render(request, \"pizzas/index.html\", context)\n\n\n@require_http_methods([\"POST\"])\ndef cancel_order(request):\n    \"\"\"View that cancels a user's order.\"\"\"\n    if \"order\" in request.POST:\n        try:\n            order = get_object_or_404(FoodOrder, pk=int(request.POST[\"order\"]))\n            if not order.can_be_changed:\n                messages.error(request, _(\"You can no longer cancel.\"))\n            elif order.member == request.member:\n                order.delete()\n                messages.success(request, _(\"Your order has been cancelled.\"))\n        except Http404:\n            messages.error(request, _(\"Your order could not be found.\"))\n    return redirect(\"pizzas:index\")\n\n\n@login_required\ndef place_order(request):\n    \"\"\"View that shows the detail of the current order.\"\"\"\n    event = FoodEvent.current()\n    if not event:\n        return redirect(\"pizzas:index\")\n\n    try:\n        obj = FoodOrder.objects.get(pizza_event=event, member=request.member)\n        current_order_locked = not obj.can_be_changed\n    except FoodOrder.DoesNotExist:\n        obj = None\n        current_order_locked = False\n\n    if \"product\" in request.POST and not current_order_locked:\n        productset = Product.available_products.all()\n        if not request.user.has_perm(\"pizzas.order_restricted_products\"):\n            productset = productset.exclude(restricted=True)\n        try:\n            product = productset.get(pk=int(request.POST[\"product\"]))\n        except Product.DoesNotExist as e:\n            raise Http404(\"Pizza does not exist\") from e\n        if not obj:\n            obj = FoodOrder(pizza_event=event, member=request.member)\n        obj.product = product\n        obj.save()\n    return redirect(\"pizzas:index\")\n", "path": "website/pizzas/views.py"}], "after_files": [{"content": "from events.services import is_organiser\nfrom .models import Product, FoodOrder, FoodEvent\n\n\ndef gen_stats_pizza_orders():\n    \"\"\"Generate statistics about number of orders per product.\n\n    :return: Dict with key, value being resp. name, order count of a product.\n    \"\"\"\n    total = {}\n\n    for product in Product.objects.all():\n        total.update(\n            {product.name: FoodOrder.objects.filter(product=product).count(),}\n        )\n\n    return {\n        i[0]: i[1]\n        for i in sorted(total.items(), key=lambda x: x[1], reverse=True)[:5]\n        if i[1] > 0\n    }\n\n\ndef gen_stats_current_pizza_orders():\n    \"\"\"Generate statistics about number of orders per product of the active pizza event.\n\n    :return: Dict with key, value being resp. name, order count of a product.\n    \"\"\"\n    total = {}\n\n    current_pizza_event = FoodEvent.current()\n    if not current_pizza_event:\n        return None\n\n    for product in Product.objects.filter():\n        total.update(\n            {\n                product.name: FoodOrder.objects.filter(\n                    product=product, food_event=current_pizza_event,\n                ).count(),\n            }\n        )\n\n    return {\n        i[0]: i[1]\n        for i in sorted(total.items(), key=lambda x: x[1], reverse=True)[:5]\n        if i[1] > 0\n    }\n\n\ndef can_change_order(member, food_event):\n    \"\"\"Determine if a certain member can edit orders of an event.\n\n    :param member: Member who wants to change and order\n    :param food_event: The event for which we want to change an order\n    :return: True if we can change an order else False\n    \"\"\"\n    return (\n        food_event\n        and member.has_perm(\"pizzas.change_foodorder\")\n        and is_organiser(member, food_event.event)\n    )\n", "path": "website/pizzas/services.py"}, {"content": "\"\"\"Views provided by the pizzas package.\"\"\"\nfrom django.contrib import messages\nfrom django.contrib.auth.decorators import login_required\nfrom django.http import Http404\nfrom django.shortcuts import get_object_or_404, render, redirect\nfrom django.utils.translation import gettext_lazy as _\nfrom django.views.decorators.http import require_http_methods\n\nfrom .models import FoodOrder, FoodEvent, Product\n\n\n@login_required\ndef index(request):\n    \"\"\"Overview of user order for a pizza event.\"\"\"\n    products = Product.available_products.order_by(\"name\")\n    if not request.user.has_perm(\"pizzas.order_restricted_products\"):\n        products = products.exclude(restricted=True)\n    event = FoodEvent.current()\n    try:\n        obj = FoodOrder.objects.get(food_event=event, member=request.member)\n    except FoodOrder.DoesNotExist:\n        obj = None\n    context = {\"event\": event, \"products\": products, \"order\": obj}\n    return render(request, \"pizzas/index.html\", context)\n\n\n@require_http_methods([\"POST\"])\ndef cancel_order(request):\n    \"\"\"View that cancels a user's order.\"\"\"\n    if \"order\" in request.POST:\n        try:\n            order = get_object_or_404(FoodOrder, pk=int(request.POST[\"order\"]))\n            if not order.can_be_changed:\n                messages.error(request, _(\"You can no longer cancel.\"))\n            elif order.member == request.member:\n                order.delete()\n                messages.success(request, _(\"Your order has been cancelled.\"))\n        except Http404:\n            messages.error(request, _(\"Your order could not be found.\"))\n    return redirect(\"pizzas:index\")\n\n\n@login_required\ndef place_order(request):\n    \"\"\"View that shows the detail of the current order.\"\"\"\n    event = FoodEvent.current()\n    if not event:\n        return redirect(\"pizzas:index\")\n\n    try:\n        obj = FoodOrder.objects.get(food_event=event, member=request.member)\n        current_order_locked = not obj.can_be_changed\n    except FoodOrder.DoesNotExist:\n        obj = None\n        current_order_locked = False\n\n    if \"product\" in request.POST and not current_order_locked:\n        productset = Product.available_products.all()\n        if not request.user.has_perm(\"pizzas.order_restricted_products\"):\n            productset = productset.exclude(restricted=True)\n        try:\n            product = productset.get(pk=int(request.POST[\"product\"]))\n        except Product.DoesNotExist as e:\n            raise Http404(\"Pizza does not exist\") from e\n        if not obj:\n            obj = FoodOrder(food_event=event, member=request.member)\n        obj.product = product\n        obj.save()\n    return redirect(\"pizzas:index\")\n", "path": "website/pizzas/views.py"}]}