Closed robnewman closed 11 years ago
@robnewman, in time I wrote this app, I have not used flatpages in urls like you showed.
Reading django 1.4.1 code right now, this include just to all django.ontrib.flatpges.views.flatpage, and, in that, we have nothing that I can connect and do breadcrumb 'magic'.
I check it fast, but as I see now, we have two options: 1 - Copy flatpage view to breadcrumbs, and change it to show breadcrumb. 2 - Write some decorator to apply to url, but I don't know if decoratores in urls.py work for includes.
I'll have time only by Sunday now, so if u want to fix with one of these options, I'll love to merge a pull request :).
Thanks for the rapid response. If I get time today or over the weekend I will fork and try to fix it.
Deal. With that fixed I issue release 1.1.2
I am actually starting to wonder if this is a non-issue. You can add a pseudo catchall by adding:
urlpatterns += patterns('django.contrib.flatpages.views',
(r'^flatpagedirectory/$', 'flatpage'),
)
This will direct any request below 'flatpagedirectory/' to the flatpages app and your breadcrumbs resolve correctly.
You just have to ensure that is is placed below all your other url patterns so that it doesn't override your app specific views. Any request that doesn't match an app or a flatpage will just return a 404 anyway.
What do you think? If you agree, you could probably close this issue as a won't fix.
No, we really have a issue.
The (r'^flatpagedirectory/$', 'flatpage')
returns a flatpage in url /flatpagedirectory/
. If it exists in DB we go to stock flatpage view, and revelant code is at http://goo.gl/cmuCO ... if you see my code at http://goo.gl/ubo8j they are pretty similar, except that with flatpage object I call breadcrumbs_for_flatpages
to build breadcrumbs.
So if we use stock flatpage view, we can't call breadcrumbs_for_flatpages
and don't have breadcrumbs loaded (this apply to all examples in Django doc: http://goo.gl/iCvf3).
Now looking better at issue, to fix this we should:
1 - create a breadcrumbs.views.flatpage
, that, is same as django.contrib.flatpages.views.flatpage
, with addition of the call to breadcrumbs_for_flatpages
like in current breadcrumbs.middleware.FlatpageFallbackMiddleware
2 - Make breadcrumbs.middleware.FlatpageFallbackMiddleware
use that view, like stock middleware
3 - Change breadcrumbs docs to instruct to use breadcrumbs.views.flatpage
instead django.contrib.flatpages.views.flatpage
in url conf.
Sounds like you have a good grasp of how to fix it (at least better than me right now).
If you are using Django's flatpages app, the following will work with django-breadcrumbs:
This gets cumbersome if you have many flatpages. A common approach to handle this is to specify a catchall term as the last entry in urls.py:
Implementing the latter scenario with django-breadcrumbs (at least under Django 1.4) results in no breadcrumbs being generated.
Is this intentional, a side-effect, or a bug? I am not entirely sure.