This post has been archived

Django CMS Urls not reversing properly

I recently encountered a strange problem when making use of a custom AppHook with django-cms. When I mounted a custom app on a cms page, reversing the urls in the template for that app (using get_absolute_url) was producing incorrect urls. Specifically, the portion of the url representing the page wasn’t present:

<!-- The incorrect url being generated. -->
<a href="//bar/baz/">..</a>

<!-- The url I should have been getting (where 'foo' is the name/url of my cms page)  -->
<a href="/foo/bar/baz/">...</a>

A post on Stack Overflow pointed me in the right direction. I had removed cms.middleware.multilingual.MultilingualURLMiddleware from my middleware settings, but still had a CMS_LANGUAGES tuple included in my settings file. This combination seems to upset django-cms so once I removed the CMS_LANGUAGES settings, the urls were back to being generated correctly.