Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8727741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:29:36+00:00 2026-06-13T08:29:36+00:00

I’m using django-cms with apphooks to display book detail information. I need the page

  • 0

I’m using django-cms with apphooks to display book detail information. I need the page with the app hook to accept a slug that specifies which book to display.

I created a page called ‘books’ and added the apphook ‘BookDetailApp’.

Here’s what my books.cms_app file looks like:

class BooksApp (CMSApp):
    name = _('Book Detail Page Application')
    urls = ['books.urls']

apphook_pool.register(BooksApp)

Here’s what my books.urls looks like:

urlpatterns = patterns('',
    url(r'^(?P<slug>[\w\-]+)?', BookDetailView.as_view(), name='book_detail'),
)

And here’s what my books.views file looks like:

class BookDetailView (DetailView):
    model = Book
    template_name = 'layouts/book-detail.html'
    context_object_name = 'book'

This all works fine when I go directly to book detail page.
So going to http://localhost:8000/books/the-book-slug/ works exactly how I want to.

The problem is that I need be able to link to specific book detail pages from promos on the home page and none of the expected methods are working for me.

Using the page_url template tag from django-cms doesn’t work because it only accepts one argument, so i can’t provide the slug needed to determine which book to display:

<a href="{% page_url 'book_detail' %}">go</a>

As expected this only redirects to http://localhost:8000/books/ which throws an error because the required slug was not included.

So my next options are to use the url template tag or defining an get_absolute_url() function on the model. Neither of these options work:

<a href="{% url book_detail book.slug %}">go</a>

def get_absolute_url(self):
    return reverse('book_detail', args=[self.slug])

These both result in a NoReverseMatch: Reverse for 'book_detail' not found error.

If I include the books.urls conf in my main url conf then it works. So it would appear that if the url is only being used by a cms apphook that it can’t be reversed by django.

Including books.urls in my main urls seems like a dirty solution and I definitely do not want to hardcode the urls in the template or the get_absolute_url function. Neither of those solutions seems very ‘pythonesque’.

Any suggestions?

EDIT:

Reverse works only if I use the language namespace. According to documentation specifying language namespace shouldn’t be required.

>>> reverse('en:book_detail', args=[book.slug])
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:29:37+00:00Added an answer on June 13, 2026 at 8:29 am

    This was apparently due to our application having cms.middleware.multilingual.MultilingualURLMiddleware which then forced all {% url %} template tags and the reverse() function to require the language namespace.

    Since our site is not localized, removing the middleware worked fine. The documentation didn’t seem that clear to me on this and finally found the answer from another source.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
In my XML file chapters tag has more chapter tag.i need to display chapters
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.