Search code examples
pythondjangodjango-cms

How do i make djangoCMS urls to work with my django app urls?


I'm developing a django site and i have built all my templates and then decided to install djangoCMS to manage my content, so the problem is that my django url patterns don't seem to work with djangoCMS page generated paths and this is causing a serious problem with the placeholders in my template pages since they only show up on structure view when i navigate to a djangoCMS page generated path but when i access the same page with my own defined urls the placeholders are not visible in structure view of the page? what might be causing this problem?


Solution

  • You'll need to modify your existing apps to be compatible with CMS & then you can attach them to pages using the app hook attribute.

    You can read the docs on creating app hooks here; http://docs.django-cms.org/en/latest/how_to/apphooks.html

    Essentially you will create a cms_apps.py file in your applications which look something like this;

    from cms.app_base import CMSApp
    from cms.apphook_pool import apphook_pool
    from django.utils.translation import ugettext_lazy as _
    
    @apphook_pool.register
    class MyApphook(CMSApp):
        name = _("My Apphook")
    
        def get_urls(self, page=None, language=None, **kwargs):
            return ["myapp.urls"]
    

    Once you've setup your app, you might want to create menus for it so that privileged users can perform admin tasks without leaving the frontend. There's info on that here; http://docs.django-cms.org/en/latest/how_to/apphooks.html#apphook-menus