RoutablePageMixin работает локально, но не работает на Heroku

Я нахожусь в процессе постепенного обновления старого сайта Wagtail CMS. Я только что обновился с Wagtail V2.13.5 до 2.15.6, включая обновление с Django 3.1 до 3.2 и Python с 3.8 до 3.10.

Сайт работает на 100% нормально на моей локальной dev-копии (Win10) и на 95% нормально на моей среде Heroku staging. Однако части сайта, использующие RoutablePageMixin, не работают в моей среде Heroku staging (стек Heroku-22).

Сайт представляет собой довольно простой блог, с индексной страницей ('/explore/') под главной страницей, и я использую RoutablePageMixin для создания "последней" страницы ('/explore/latest/') для отображения 5 последних сообщений под ней.

Эти страницы '/explore/' и '/explore/latest/' прекрасно работают локально, но в моем окружении Heroku staging '/explore/' работает нормально, а '/explore/latest/' просто выдает 404 ошибку ('rasied by wagtail.core.views.serve)'. В логах Heroku нет ничего, что объясняло бы причину этого, он просто не распознает @route(r'^latest/$') вообще.

from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.db import models
from django.shortcuts import render, redirect
from modelcluster.fields import ParentalKey, ParentalManyToManyField
from modelcluster.contrib.taggit import ClusterTaggableManager
from taggit.models import TaggedItemBase
from wagtail.api import APIField
from wagtail.core.models import Page, Orderable
from wagtail.contrib.routable_page.models import RoutablePageMixin, route

# Location Index Page
class LocationIndexPage(RoutablePageMixin,Page):
    parent_page_types = ['home.HomePage']
    subpage_types = ['locations.LocationPage']

    def get_context(self, request, *args, **kwargs):
        context = super().get_context(request, *args, **kwargs)

        ## Find all published Location Pages so these can be acessed
        ## and displayed on the page
        locations = LocationPage.objects.live().order_by('-first_published_at')

        ## Check if there is a ?tag= query string, and if so, filter
        ## the list of Location Pages to include only those with the tag
        if request.GET.get('tag', None):
            tags = request.GET.get('tag')
            locations = locations.filter(tags__slug__in=[tags])
            context['tag_name'] = tags
            if not locations:
                context['tag_not_found'] = 'true'

        ## Initial pagination
        paginator = Paginator(locations, 10)

        ## Check if valid 'page' query string is in the URL 
        page = request.GET.get("page")
        try:
            posts = paginator.page(page)
        except PageNotAnInteger: ## If there is something like 'page=abc' in the URL, default to the first page
            posts = paginator.page(1)
        except EmptyPage: ## If there is a page number higher than the available page numbers, show the last page
            posts = paginator.page(paginator.num_pages)

        context["posts"] = posts

        ## Make selected Location Pages available in the template
        context['locations'] = locations

        ## Make a list of categories available in the template
        allcategories = LocationCategory.objects.all()
        context['categories'] = allcategories

        return context

    @route(r'^latest/$')
    def latest_blog_posts(self, request, *args, **kwargs):
        latest_posts = LocationPage.objects.live().public()[:5]
        return self.render(
            request, 
            context_overrides={
                'latest_posts': latest_posts,
            },
            template="locations/latest_posts.html", 
        )

Поскольку локально все работает нормально, я в некотором замешательстве, как устранить неполадки. Насколько я могу судить по документации, я использую RoutablePageMixin, как и ожидалось для этой версии Wagtail: https://docs.wagtail.org/en/v2.15.6/reference/contrib/routablepage.html

(Для дополнительного контекста: помимо того, что этот код отлично работает локально на Wagtail v2.15.6/Django 3.2/Python 3.10, он также на 100% работает в моей производственной среде на Heroku, которая использует стек Heroku-18, а не Heroku-22, а также Wagtail v2.13.5, Django 3.1 и Python 3.8. Я не могу повторить эту настройку для моей среды Staging, так как стеки, доступные для новых приложений на Heroku, больше не поддерживают Python 3.8).

Любая помощь в этом будет принята с благодарностью!

Вернуться на верх