Search code examples
pythondjangodjango-cms

How can I ensure Django CMS initializes app urls?


I'm trying to boot up a Django CMS app. All the app hooks are properly set up and registered. For an example take the NewsHook:

class NewsHook(CMSApp):
    """ A class to hook the News into the django cms
    """
    name = ("News")
    urls = ["apps.news.urls"]


apphook_pool.register(NewsHook)

The urls.py of this hook includes the following:

urlpatterns = [
    # /feed/
    url(r'^feed/$', ArticlesFeed(), name='news_feed'),
]

And the urls.py of the project (under the settings folder) includes the following relevant lines:

admin.autodiscover()

urlpatterns = patterns(
    '',
    ...
    # / -> Django CMS
    url(r'^', include('cms.urls')),
)

All this looks normal, right? But when I visit the home page, I get NoReverseMatch error:

enter image description here

Not sure what I am doing wrong... Is there a side of this that I'm not seeing? Btw, this app runs well on production, so it doesn't have any bugs as far as I can see.

My Specs

  • Django version: 1.8.13
  • Django CMS version: 3.3.0
  • Python version: 2.7.

Solution

  • I discovered that these Django CMS apps need to be attached to a page in order to add the urls to the project. I loaded the pages table from the production and the urls started functioning.

    Making the urls dependent on the presence of a page is really counterintuitive to me, coming from Rails.