question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reverse failing (NoReverseMatch) for newly added apphooks

See original GitHub issue

Steps

Add an apphook to a (published) Django-CMS page. The application is added only once. The model of that application uses reverse() for its get_absolute_url() override.

Expecting

Should work, and it works after restarting the server that was started in via runserver

Actual

When running LiveServerTestCase that import those pages via fixtures, or when adding the apphook the first time and before restarting the server, it’ll fail on page load (the actual page calling reverse) with:

NoReverseMatch: Reverse for 'XXX' with arguments '('123')' and keyword arguments '{}' not found. 0 pattern(s) tried: []

Environment

  • Linux
  • django-cms==3.0.1
  • Django==1.6.4

catalog/cms_app.py

class CatalogApphook(CMSApp):
    name = _("XXX")
    urls = ["catalog.urls"]

apphook_pool.register(CatalogApphook)

catalog/url.py

from django.conf.urls import url, patterns

urlpatterns = patterns('catalog.views',
    url(r'^([\w-]{1,40})/$', 'catalog'),
)

url.py

urlpatterns = i18n_patterns('',
    url(r'^accounts/login/$', login),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^', include('cms.urls')),
) + static(
    settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
)

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
wernightcommented, May 15, 2014

I saw a similar page but saying “When you run manage.py runserver a restart should not be needed.” at http://django-cms.readthedocs.org/en/3.0.1/extending_cms/app_integration.html#automatically-restart-server-on-apphook-changes

Thanks for the feedback, I’ll try those functions. There are clear_app_resolvers() and clear_url_caches() calls all over the place; It would be good to simplify this by one of:

  • Just working without further work while testing
  • Requiring tests to derive from another base class
  • Simplifying the functions required to be called on setup.
0reactions
wernightcommented, May 22, 2014

Thanks. Actually both looked kind of related but the second is really what I want.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reverse failing (NoReverseMatch) for newly added apphooks
Steps Add an apphook to a (published) Django-CMS page. The application is added only once. The model of that application uses reverse() for ......
Read more >
NoReverseMatch at / Reverse for 'product_list_by_category ...
Everytime I run my django project, I get this error NoReverseMatch at / Reverse for 'product_list_by_category' with keyword arguments ...
Read more >
NoReverseMatch at / Reverse for 'submit' with arguments ...
I have been getting this NoReverseMatch error or I cannot properly process the POST data. I am new with Django so I have...
Read more >
Complex apphook configuration - django CMS documentation
It provides the fallback namespace for views and templates that reverse URLs. ... If they don't, your pages using them will throw up...
Read more >
How to create apphooks — django cms 3.10.0 documentation
If you fail to do this, then any templates in the application that invoke URLs using the form {% url 'myapp:index' %} or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found