from django.db import models
from django.http import HttpResponse
from django.conf.urls import url

from wagtail.contrib.wagtailroutablepage.models import RoutablePage


def routable_page_external_view(request, arg):
    return HttpResponse("EXTERNAL VIEW: " + arg)

class RoutablePageTest(RoutablePage):
    subpage_urls = (
        url(r'^$', 'main', name='main'),
        url(r'^archive/year/(\d+)/$', 'archive_by_year', name='archive_by_year'),
        url(r'^archive/author/(?P<author_slug>.+)/$', 'archive_by_author', name='archive_by_author'),
        url(r'^external/(.+)/$', routable_page_external_view, name='external_view')
    )

    def archive_by_year(self, request, year):
        return HttpResponse("ARCHIVE BY YEAR: " + str(year))

    def archive_by_author(self, request, author_slug):
        return HttpResponse("ARCHIVE BY AUTHOR: " + author_slug)

    def main(self, request):
        return HttpResponse("MAIN VIEW")

from django.db import models
from django.http import HttpResponse
from django.conf.urls import url

from wagtail.contrib.wagtailroutablepage.models import RoutablePage


def routable_page_external_view(request, arg):
    return HttpResponse("EXTERNAL VIEW: " + arg)

class RoutablePageTest(RoutablePage):
    @property
    def subpage_urls(self):
        return (
            url(r'^$', self.main, name='main'),
            url(r'^archive/year/(\d+)/$', self.archive_by_year, name='archive_by_year'),
            url(r'^archive/author/(?P<author_slug>.+)/$', self.archive_by_author, name='archive_by_author'),
            url(r'^external/(.+)/$', routable_page_external_view, name='external_view')
        )

    def archive_by_year(self, request, year):
        return HttpResponse("ARCHIVE BY YEAR: " + str(year))

    def archive_by_author(self, request, author_slug):
        return HttpResponse("ARCHIVE BY AUTHOR: " + author_slug)

    def main(self, request):
        return HttpResponse("MAIN VIEW")

Make subpage_urls a property on RoutablePageTest
Make subpage_urls a property on RoutablePageTest

  from django.db import models
  from django.http import HttpResponse
  from django.conf.urls import url
  
  from wagtail.contrib.wagtailroutablepage.models import RoutablePage
  
  
  def routable_page_external_view(request, arg):
      return HttpResponse("EXTERNAL VIEW: " + arg)
  
  class RoutablePageTest(RoutablePage):
-     subpage_urls = (
+     @property
+     def subpage_urls(self):
+         return (
-         url(r'^$', 'main', name='main'),
+             url(r'^$', self.main, name='main'),
-         url(r'^archive/year/(\d+)/$', 'archive_by_year', name='archive_by_year'),
+             url(r'^archive/year/(\d+)/$', self.archive_by_year, name='archive_by_year'),
-         url(r'^archive/author/(?P<author_slug>.+)/$', 'archive_by_author', name='archive_by_author'),
+             url(r'^archive/author/(?P<author_slug>.+)/$', self.archive_by_author, name='archive_by_author'),
-         url(r'^external/(.+)/$', routable_page_external_view, name='external_view')
+             url(r'^external/(.+)/$', routable_page_external_view, name='external_view')
-     )
+         )
  
      def archive_by_year(self, request, year):
          return HttpResponse("ARCHIVE BY YEAR: " + str(year))
  
      def archive_by_author(self, request, author_slug):
          return HttpResponse("ARCHIVE BY AUTHOR: " + author_slug)
  
      def main(self, request):
          return HttpResponse("MAIN VIEW")
  
Make subpage_urls a property on RoutablePageTest
## Code Before:
from django.db import models
from django.http import HttpResponse
from django.conf.urls import url

from wagtail.contrib.wagtailroutablepage.models import RoutablePage


def routable_page_external_view(request, arg):
    return HttpResponse("EXTERNAL VIEW: " + arg)

class RoutablePageTest(RoutablePage):
    subpage_urls = (
        url(r'^$', 'main', name='main'),
        url(r'^archive/year/(\d+)/$', 'archive_by_year', name='archive_by_year'),
        url(r'^archive/author/(?P<author_slug>.+)/$', 'archive_by_author', name='archive_by_author'),
        url(r'^external/(.+)/$', routable_page_external_view, name='external_view')
    )

    def archive_by_year(self, request, year):
        return HttpResponse("ARCHIVE BY YEAR: " + str(year))

    def archive_by_author(self, request, author_slug):
        return HttpResponse("ARCHIVE BY AUTHOR: " + author_slug)

    def main(self, request):
        return HttpResponse("MAIN VIEW")

## Instruction:
Make subpage_urls a property on RoutablePageTest
## Code After:
from django.db import models
from django.http import HttpResponse
from django.conf.urls import url

from wagtail.contrib.wagtailroutablepage.models import RoutablePage


def routable_page_external_view(request, arg):
    return HttpResponse("EXTERNAL VIEW: " + arg)

class RoutablePageTest(RoutablePage):
    @property
    def subpage_urls(self):
        return (
            url(r'^$', self.main, name='main'),
            url(r'^archive/year/(\d+)/$', self.archive_by_year, name='archive_by_year'),
            url(r'^archive/author/(?P<author_slug>.+)/$', self.archive_by_author, name='archive_by_author'),
            url(r'^external/(.+)/$', routable_page_external_view, name='external_view')
        )

    def archive_by_year(self, request, year):
        return HttpResponse("ARCHIVE BY YEAR: " + str(year))

    def archive_by_author(self, request, author_slug):
        return HttpResponse("ARCHIVE BY AUTHOR: " + author_slug)

    def main(self, request):
        return HttpResponse("MAIN VIEW")
