Including external Django Apps in Breadcrumbs and Menus

227 views
Skip to first unread message

John Schofield

unread,
May 13, 2013, 2:55:37 PM5/13/13
to mezzani...@googlegroups.com
First of all, let me say how happy I am with Mezzanine! I'm finding it incredibly powerful and adaptable, and I'm getting more enthusiastic about it every time I use it.

I'm trying to add a knowledge base to my site with the django-knowledge Django app. I want it to be included in the menu, and in the breadcrumbs, but it's not happening. Based on the following reading, I thought I was doing it right:


I've put django-knowledge in my urls.py:

...
url(r'^blogs/backstage/', direct_to_template, {'template': 'en_blogbackstage.html'}, name='en_blogbackstage'),
url(r'^learn/, direct_to_template, {'template': 'en_learn.html'}, name='en_learn'),
url(r'^learn/ask/', include('knowledge.urls')),
("^", include("mezzanine.urls")),

I've created a rich-text page at learn and at learn/ask.

The menu and breadcrumbs work properly when I'm not at the learn/ask URL. When I click on the learn/ask URL in the menu, I go to the correct place, but the menu and breadcrumbs behave as though I'm on the home page, not the learn/ask page.

Examples of the learn and learn/ask page are below:



I can make any changes necessary to the django-knowledge templates, but prefer not to fork their code and modify it unless absolutely necessary. Is there anything I'm doing wrong? Anything I can do to make this work?

Thanks very much!


John Schofield 

Stephen McDonald

unread,
May 13, 2013, 5:08:18 PM5/13/13
to mezzani...@googlegroups.com
It should work as you expect.

Can you double-check the URL field is "learn/ask" for that page record? The URL field should actually be hidden in the admin, since the page is considered to be "protected", since it points to a fixed urlpattern provided by your app, so you might have to jump into the Django shell to confirm.



John Schofield 

--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Stephen McDonald
http://jupo.org

John Schofield

unread,
May 13, 2013, 5:38:56 PM5/13/13
to mezzani...@googlegroups.com, st...@jupo.org
The URL field was indeed protected in the admin. From the shell:

>>> from mezzanine.pages.models import Page
>>> p = Page.objects.all()
>>> p[14]
<Page: Learn / Ask>
>>> p[14].get_slug()
u'learn/ask'
>>> p[14].get_absolute_url()
'/learn/ask/'

Any other diagnostics I should attempt?

Stephen McDonald

unread,
May 13, 2013, 9:18:17 PM5/13/13
to mezzani...@googlegroups.com
It looks like the knowledge app isn't 100% compatible with Mezzanine. Its views return regular HttpResponse objects instead of TemplateResponse objects, so we're unable to inject the current page into the template used, which the menus are dependant on.

We might be able to improve this in the future, but for now you can probably get things working with this naughty little patch:

In your project's urls.py:

from mezzanine.utils.views import render
from knowledge import views
views.render = render

I tried this and it initially works for me - your mileage may vary.


On Tue, May 14, 2013 at 4:55 AM, John Schofield <j...@schof.org> wrote:


John Schofield 

--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

John Schofield

unread,
May 13, 2013, 9:37:58 PM5/13/13
to mezzani...@googlegroups.com, st...@jupo.org
Thanks very much, Stephen -- this naughty little patch worked beautifully!

Take care, Stephen!

John
Reply all
Reply to author
Forward
0 new messages