django-blog-zinnia / cmsplugin-zinnia

Bridge between django-blog-zinnia and django-cms
BSD 3-Clause "New" or "Revised" License
53 stars 46 forks source link

NoReverseMatch raised if blog apphook doesn't exist #12

Closed Lacrymology closed 10 years ago

Lacrymology commented 11 years ago

If cmsplugin_zinnia is in INSTALLED_APPS and the {% menu %} templatetag is called from the base template, or wherever, and no page is created linked with the zinnia apphook, then a NoReverseMatch is raised.

I don't really understand why this menu entry is even processed if there's no apphooked page

I'm not sure if this is a cmsplugin_zinnia or a django-cms issue

vskh commented 11 years ago

Same for me!

vskh commented 11 years ago

From my point of view this is more django-cms-related. Here is why I think so.

I had similar issue with old cmsplugin_news: whenever you add plugin on the page so that is registers its menu you get NoReverseMatch since no its urls are included in urlpatterns.

I tried workaround for cmsplugin_zinnia as follows: if I add zinnia.urls to urlpatterns after cms.urls so that they are included in patterns but do not intercept routing then error will go away and I am able to add plugins to placeholders. Although in this case for everything to work urls must be included with correct path prefix (otherwise reversed urls in plugins content are invalid). So maybe it's reasonable: you need to bind application to some page so that app urls were mapped correctly somewhere in current sitemap before adding any plugins. But it is definitely incorrect that right after you enable app via INSTALLED_APPS it causes NoReverseMatch leading you to some temporary workarounds like one I used to just set it up.

I guess we need to ask someone from django-cms.

Lacrymology commented 11 years ago

I placed the same bug on their github, but there's been no response: https://github.com/divio/django-cms/issues/1649

The thing is, well, if you actually reach an {% url %} templatetag or a .reverse() in an actual active view, then it's OK that this raises, but the Menus should catch the NoReverseMatch if the scenario is simply that the apphook's not there, or maybe they shouldn't be processed at all if they're not actually included somewhere

vskh commented 11 years ago

I suppose that with the way show_menu template-tag works there can't be other behavior than NoReverseMatch. Or I may not fully understand the code this late night after day of djangoing.

murdav commented 11 years ago

Instead I have this error (Django 1.5.1 + Django-cms 2.4.1): No registered apphook BlogApphook found. /srv/virtualenvs/fm/local/lib/python2.7/site-packages/cms/apphook_pool.py in get_apphook, line 70

Ideas?

Fantomas42 commented 10 years ago

I close the issue, because it seems related to django-cms.

Regards