django-cms / djangocms-frontend

django CMS frontend is a plugin bundle for django CMS providing several components for the frontend, currently implemented with the popular Bootstrap 5 framework.
Other
43 stars 20 forks source link

Link autocomplete URL is uninstalled after Apphook reload #135

Closed bielfrontera closed 1 year ago

bielfrontera commented 1 year ago

Describe the bug Under some circumstances, we get a 500 error after opening the dialog to modify a Link. The error is NoReverseMatch 'dcf_autocomplete' is not a registered namespace, raised from a djangocms_frontend.contrib.link.forms.Select2jqWidget object.

After some digging, we notice that ApphookReloadMiddleware reloads the URLs configuration when a new application is added to the pages tree. And in this case, the URL that is installed by djangocms_frontend is no longer available.

To Reproduce Steps to reproduce the behavior:

  1. Check that "cms.middleware.utils.ApphookReloadMiddleware" is included at MIDDLEWARE settings variable.
  2. Create a new page, configure it as an app hook and publish it (you'll see this message at the server console: Application url changed and urls_need_reloading signal fired. Please reload the urls.py or restart the server.)
  3. Edit any link in any page. You'll get a NoReverseMatch error
fsbraun commented 1 year ago

@bielfrontera Thank you for pointing this out! Also, your analysis is extremely helpful 👍

fsbraun commented 1 year ago

@bielfrontera Could you support a fix by testing the PR #136?

bielfrontera commented 1 year ago

Hi @fsbraun, yes, I've tested in my environment with the fix and now it works fine! I've tested the link plugin in some scenarios with no problem (adding, modifying and removing apphooks to force urls reload).

Thanks!

fsbraun commented 1 year ago

Great! Will go into the next bugfix release!