prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  get_last_root_page template tag not working
  ### Describe the Bug
  <!-- A clear and concise description of what the bug is. -->
  The `get_last_root_page` template tag is not working:
  https://github.com/Integreat/integreat-cms/blob/develop/src/cms/templatetags/page_filters.py#L10-L20
  
  This is because in the page QuerySet aggregation, the difference() function is used:
  https://github.com/Integreat/integreat-cms/blob/a285cb3c74b2a2c501147076338e2b2a70c89bd6/src/cms/models/regions/region.py#L177
  
  After difference(), it is not possible to use filter(), see https://docs.djangoproject.com/en/2.2/ref/models/querysets/#union
  
  This leads to the last drop-region in the page tree being incorrectly tied to the last page in the list, not necessarily the last root page.
  
  ### Steps to Reproduce
  
  1. Go to Page tree
  2. Drag & drop page to most bottom line
  
  ### Expected Behavior
  <!-- A clear and concise description of what you expected to happen. -->
  The page should be placed next to the last root page
  
  ### Actual Behavior
  <!-- A clear and concise description of what actually happened. -->
  The page is placed next to the last page in the list
  
  ### Additional Information
  <!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `src/cms/templatetags/page_filters.py`
  Content:
  ```
  1 """
  2 This is a collection of tags and filters for :class:`~cms.models.pages.page.Page` objects.
  3 """
  4 from django import template
  5 
  6 register = template.Library()
  7 
  8 
  9 @register.simple_tag
  10 def get_last_root_page(pages):
  11     """
  12     This tag returns the last page on the root level.
  13 
  14     :param pages: The requested page tree
  15     :type pages: ~mptt.querysets.TreeQuerySet [ ~cms.models.pages.page.Page ]
  16 
  17     :return: The last root page of the given :class:`~django.db.models.query.QuerySet`
  18     :rtype: ~cms.models.pages.page.Page
  19     """
  20     return pages.filter(parent=None).last()
  21
  ```
  --- 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/src/cms/templatetags/page_filters.py b/src/cms/templatetags/page_filters.py
  --- a/src/cms/templatetags/page_filters.py
  +++ b/src/cms/templatetags/page_filters.py
  @@ -12,9 +12,9 @@
       This tag returns the last page on the root level.
   
       :param pages: The requested page tree
  -    :type pages: ~mptt.querysets.TreeQuerySet [ ~cms.models.pages.page.Page ]
  +    :type pages: list [ ~cms.models.pages.page.Page ]
   
  -    :return: The last root page of the given :class:`~django.db.models.query.QuerySet`
  +    :return: The last root page of the given page list
       :rtype: ~cms.models.pages.page.Page
       """
  -    return pages.filter(parent=None).last()
  +    return list(filter(lambda p: not p.parent, pages))[-1]
  
verification_info: {"golden_diff": "diff --git a/src/cms/templatetags/page_filters.py b/src/cms/templatetags/page_filters.py\n--- a/src/cms/templatetags/page_filters.py\n+++ b/src/cms/templatetags/page_filters.py\n@@ -12,9 +12,9 @@\n     This tag returns the last page on the root level.\n \n     :param pages: The requested page tree\n-    :type pages: ~mptt.querysets.TreeQuerySet [ ~cms.models.pages.page.Page ]\n+    :type pages: list [ ~cms.models.pages.page.Page ]\n \n-    :return: The last root page of the given :class:`~django.db.models.query.QuerySet`\n+    :return: The last root page of the given page list\n     :rtype: ~cms.models.pages.page.Page\n     \"\"\"\n-    return pages.filter(parent=None).last()\n+    return list(filter(lambda p: not p.parent, pages))[-1]\n", "issue": "get_last_root_page template tag not working\n### Describe the Bug\r\n<!-- A clear and concise description of what the bug is. -->\r\nThe `get_last_root_page` template tag is not working:\r\nhttps://github.com/Integreat/integreat-cms/blob/develop/src/cms/templatetags/page_filters.py#L10-L20\r\n\r\nThis is because in the page QuerySet aggregation, the difference() function is used:\r\nhttps://github.com/Integreat/integreat-cms/blob/a285cb3c74b2a2c501147076338e2b2a70c89bd6/src/cms/models/regions/region.py#L177\r\n\r\nAfter difference(), it is not possible to use filter(), see https://docs.djangoproject.com/en/2.2/ref/models/querysets/#union\r\n\r\nThis leads to the last drop-region in the page tree being incorrectly tied to the last page in the list, not necessarily the last root page.\r\n\r\n### Steps to Reproduce\r\n\r\n1. Go to Page tree\r\n2. Drag & drop page to most bottom line\r\n\r\n### Expected Behavior\r\n<!-- A clear and concise description of what you expected to happen. -->\r\nThe page should be placed next to the last root page\r\n\r\n### Actual Behavior\r\n<!-- A clear and concise description of what actually happened. -->\r\nThe page is placed next to the last page in the list\r\n\r\n### Additional Information\r\n<!-- Add any other context (e.g. logs, screenshots, etc.) about the problem here. -->\r\n\r\n\n", "before_files": [{"content": "\"\"\"\nThis is a collection of tags and filters for :class:`~cms.models.pages.page.Page` objects.\n\"\"\"\nfrom django import template\n\nregister = template.Library()\n\n\n@register.simple_tag\ndef get_last_root_page(pages):\n    \"\"\"\n    This tag returns the last page on the root level.\n\n    :param pages: The requested page tree\n    :type pages: ~mptt.querysets.TreeQuerySet [ ~cms.models.pages.page.Page ]\n\n    :return: The last root page of the given :class:`~django.db.models.query.QuerySet`\n    :rtype: ~cms.models.pages.page.Page\n    \"\"\"\n    return pages.filter(parent=None).last()\n", "path": "src/cms/templatetags/page_filters.py"}], "after_files": [{"content": "\"\"\"\nThis is a collection of tags and filters for :class:`~cms.models.pages.page.Page` objects.\n\"\"\"\nfrom django import template\n\nregister = template.Library()\n\n\n@register.simple_tag\ndef get_last_root_page(pages):\n    \"\"\"\n    This tag returns the last page on the root level.\n\n    :param pages: The requested page tree\n    :type pages: list [ ~cms.models.pages.page.Page ]\n\n    :return: The last root page of the given page list\n    :rtype: ~cms.models.pages.page.Page\n    \"\"\"\n    return list(filter(lambda p: not p.parent, pages))[-1]\n", "path": "src/cms/templatetags/page_filters.py"}]}