RoutablePageMixin routes not working

160 views
Skip to first unread message

David

unread,
Aug 22, 2016, 7:00:38 PM8/22/16
to Wagtail support
Hi all,

I've got a model defined similar to below:
class ObjPage(RoutablePageMixin, Page):
    body_content = StreamField([
            ('heading', blocks.CharBlock(classname="full title",icon="title")),
            ('paragraph', blocks.RichTextBlock()),
            ('image', ImageChooserBlock(icon="image")),
        ], null=True, blank=True)
    content_panels = Page.content_panels + [
        FieldPanel('body', classname="full"),
        StreamFieldPanel('body_content'),
    ]

    @route(_(r'^slug/(?P<slug>[\w-]+)/$'))
    def detail(self, request, slug):
        obj = Items.objects.get(slug=slug)
        return render(request, 'detail.html', {'self': self, 'object': obj})

Oddly enough, the routablepageurl templatetag works great using the above route to come up with URLs. However, when I attempt to actually use the URLs in question I am only getting 404s. Any ideas as to what's going on? I added some debugging print statements and they haven't been firing at all.

Thanks!

David

unread,
Aug 23, 2016, 3:00:26 PM8/23/16
to Wagtail support
I debugged things a little further and discovered that Wagtail won't route to the RoutablePageMixin routes when the slug for the page created by the RoutablePageMixin is covered by (wagtail-)modeltranslation. If the model isn't covered by the translation everything works fine, but as soon as it is, Wagtail will no longer route. The same problem doesn't exist for regular pages, so is there something odd happening here with the RoutablePageMixin's interpretation of the slug? For test purposes I tried with the two language slugs set identically and different, neither having any impact. It strikes me that this is a Wagtail issue rather than a modeltranslation issue, but I'm not certain.

Any ideas?
Reply all
Reply to author
Forward
0 new messages