dreipol / djangocms-spa-vue-js

Run your django CMS project as a single-page application (SPA) with vue.js and vue-router.
MIT License
59 stars 9 forks source link

Compatibility with latest versions of django-cms and django #5

Open ghost opened 5 years ago

ghost commented 5 years ago

Description

I tried to start a project with Django 1.11 and different versions of Django CMS (3.5.x, 3.4.6, 3.4.5) without success. There was a wrong import in djangocms_spa.views (get_page_from_request wasn't in cms.utils.page_resolver anymore, now it is found in cms.utils.page) that i quickly fixed.

Unfortunately when I use the {% vue_js_router %} template tag I can only see a JSON object with the "routes" key set to an empty array.

    {
        "routes": [] 
    }

Digging up a bit, it appears that this is caused by a cache decorator wrapped around the _get_menu_renderer() function defined in cms.context_processors:

@lru_cache.lru_cache(maxsize=None)
def _get_menu_renderer():
    # We use lru_cache to avoid getting the manager
    # every time this function is called.
    from menus.menu_pool import menu_pool
    return menu_pool.get_renderer(request)

What I Did

If i comment the decorator the "routes" key in template seems to be properly set. Do you see any hazard in using this approach (avoiding the lru_cache usage)?

And, last but not least, are you thinking about mantaining this project in order to make it compatible with the latest versions of django and django-cms?