django-cms apphook urls don't work with reverse() using Python shell

234 views
Skip to first unread message

Philipp

unread,
Aug 19, 2014, 7:48:18 AM8/19/14
to django-cms...@googlegroups.com
HI everyone,

I've created a django CMS apphook. Unfortunately I'm not able to reverse apphook urls using the Python shell.

The cms_app.py file looks like:

class ArticleApp (CMSApp):
    name
= _('Article App')
    app_name
= 'article_app'
    urls
= ['article.urls']

apphook_pool
.register(ArticleApp)

This is my urls.py file:

urlpatterns = patterns('',
     url
(r'^(?P<slug>[\w\-]+)?', ArticleView.as_view(), name='article-by-slug'),
)

The template file is:

{% url 'article_app:article-by-slug' article.slug %}

URL reversing inside the template performs like expected. If I try to do the same using the Python shell I receive an error message:

>>> from django.core.urlresolvers import reverse
>>> from article.models import Article
>>> a = Article.objects.get(pk=1)
>>> reverse('article_app:article-by-slug', kwargs={'slug': a.slug})
# Reverse for 'article_app:article-by-slug' with arguments '()' and keyword arguments '{'slug': 'this-is-article-1'}' not found.

Additional urls defined in the main urls.py work like expected from inside the shell. Only apphook urls don't work.

Any suggestions? I'd appreciate your help!

Thank you!

Benjamin Wohlwend

unread,
Aug 20, 2014, 3:34:38 AM8/20/14
to django-cms...@googlegroups.com
Hi Philipp,

this mailing list is meant for discussing the development of django CMS itself. For questions about developing *with* the CMS, please use the "django-cms" group.

As for your question, it's probably due to the apphooked page not being available in the "en-us" language (the default for Django management commands, including "shell"). Try to activate the correct language before reversing.

Kind regards,
Benjamin


--
You received this message because you are subscribed to the Google Groups "django-cms-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-cms-devel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages