question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RoutablePageMixin + i18n + Preview = not working

See original GitHub issue

Today I’ve found strange issue. I have some page class:

class BlogPage(Page):
    ...

And urls.py:

urlpatterns = [
    url(r'^djangoadmin/', admin.site.urls),
    url(r'^wagtailadmin/', include(wagtailadmin_urls)),
    url(r'^doc/', include(wagtaildocs_urls)),
]

urlpatterns += i18n_patterns(
    url(r'', include(wagtail_urls)),
)

When I click “Preview” button in admin page, I see following requests:

[25/Jul/2016 13:29:19] "GET /wagtailadmin/pages/preview/ HTTP/1.1" 200 10327
[25/Jul/2016 13:29:20] "GET /wagtailadmin/pages/preview_loading/ HTTP/1.1" 200 9844
[25/Jul/2016 13:29:23] "POST /wagtailadmin/pages/19/edit/preview/ HTTP/1.1" 200 9594

And all works fine. But now I want to modify my page class:

class BlogPage(RoutablePageMixin, Page):

    @route(r'^tag/(\w+)/$', name='tag')
    def tag(self, request, tag):
    ...

Wagtail admin is still working. But when I open same page and click “Preview” - I see 404 page:

Page not found (404)
Request Method:     GET
Request URL:    http://127.0.0.1:8000/ru/wagtailadmin/pages/19/edit/preview/
Raised by:  wagtail.wagtailcore.views.serve

You can notice, that language tag appears in URI, but it shouldn’t - i18n isn’t enabled for admin pages. And now there are following requests:

[25/Jul/2016 13:35:52] "GET /wagtailadmin/pages/19/edit/ HTTP/1.1" 200 173884
[25/Jul/2016 13:35:58] "GET /wagtailadmin/pages/preview/ HTTP/1.1" 200 10326
[25/Jul/2016 13:35:59] "GET /wagtailadmin/pages/preview_loading/ HTTP/1.1" 200 9844
Not Found: /wagtailadmin/pages/19/edit/preview/
[2016-07-25 13:36:01.700] [WARNING   ] [django.request] [base/get_response] [p:320956|t:311696] || Not Found: /wagtailadmin/pages/19/edit/preview/
[25/Jul/2016 13:36:01] "POST /wagtailadmin/pages/19/edit/preview/ HTTP/1.1" 302 0
Not Found: /ru/wagtailadmin/pages/19/edit/preview/
[2016-07-25 13:36:01.755] [WARNING   ] [django.request] [base/get_response] [p:320956|t:324092] || Not Found: /ru/wagtailadmin/pages/19/edit/preview/
[25/Jul/2016 13:36:01] "GET /ru/wagtailadmin/pages/19/edit/preview/ HTTP/1.1" 404 1741

I’ve also tried to remove any routes:

class BlogPage(RoutablePageMixin, Page):
    ... (only fields here)

And requests are now:

[25/Jul/2016 13:37:17] "GET /wagtailadmin/pages/preview/ HTTP/1.1" 200 10327
[25/Jul/2016 13:37:18] "GET /wagtailadmin/pages/preview_loading/ HTTP/1.1" 200 9844
Not Found: /wagtailadmin/pages/19/edit/preview/
[2016-07-25 13:37:20.804] [WARNING   ] [django.request] [base/get_response] [p:322080|t:319612] || Not Found: /wagtailadmin/pages/19/edit/preview/
[25/Jul/2016 13:37:20] "POST /wagtailadmin/pages/19/edit/preview/ HTTP/1.1" 200 2084

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kaedrohocommented, Jul 25, 2016

I think you’re missing the “main” view on the routable page, this must be defined when you switch to using the RoutablePageMixin.

Try adding the following to your model:

from django.template import TemplateResponse


    @route(r'^$')
    def main(self, request):
        return TemplateResponse(request, self.get_template(), self.get_context())

If you need further support, please post in our support group instead: https://groups.google.com/forum/#!forum/wagtail

0reactions
andreasnuessleincommented, Feb 7, 2017

not sure if referencing this issue automatically triggers you guys to get this update so: I created a PR: #3344 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Internationalisation — Wagtail Documentation 2.15.1 ...
Enabling internationalisation; Configuring available languages ... Editors can be given permission to edit content in one locale and not others.
Read more >
[Solved]-Wagtail render any path in index page-django
This isn't possible with RoutablePageMixin ; Wagtail treats URL routing and page serving as two distinct steps, and once it's identified the function ......
Read more >
Release 4.1.1 Torchbox - Wagtail Documentation
There are a couple of problems with our blog index view: ... to leave this out when previewing, so that editor activity doesn't...
Read more >
Internationalisation — Wagtail Documentation 3.0.2 documentation
This means that to make a site available in another locale, you just need to translate and publish its homepage in that new...
Read more >
RoutablePageMixin — Wagtail 2.8.1 documentation
The RoutablePageMixin mixin provides a convenient way for a page to respond on multiple sub-URLs with different views. For example, a blog section...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found