aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Christie2011-05-24 10:40:35 +0100
committerTom Christie2011-05-24 10:40:35 +0100
commiteafda8550800a98aa37571df0cef78e32521a89b (patch)
tree684f4ae5dfb28091e9f7c976e20bcc645f85a9ed
parent370274f5640d55ef71422f7a2440710a43ff900e (diff)
downloaddjango-rest-framework-eafda8550800a98aa37571df0cef78e32521a89b.tar.bz2
Fix up breadcrumbs to only breadcrumb for REST framework Views
-rw-r--r--djangorestframework/tests/breadcrumbs.py10
-rw-r--r--djangorestframework/utils/breadcrumbs.py5
2 files changed, 9 insertions, 6 deletions
diff --git a/djangorestframework/tests/breadcrumbs.py b/djangorestframework/tests/breadcrumbs.py
index 158f1800..dc1a02bf 100644
--- a/djangorestframework/tests/breadcrumbs.py
+++ b/djangorestframework/tests/breadcrumbs.py
@@ -19,11 +19,11 @@ class NestedResourceInstance(View):
pass
urlpatterns = patterns('',
- url(r'^$', Root),
- url(r'^resource/$', ResourceRoot),
- url(r'^resource/(?P<key>[0-9]+)$', ResourceInstance),
- url(r'^resource/(?P<key>[0-9]+)/$', NestedResourceRoot),
- url(r'^resource/(?P<key>[0-9]+)/(?P<other>[A-Za-z]+)$', NestedResourceInstance),
+ url(r'^$', Root.as_view()),
+ url(r'^resource/$', ResourceRoot.as_view()),
+ url(r'^resource/(?P<key>[0-9]+)$', ResourceInstance.as_view()),
+ url(r'^resource/(?P<key>[0-9]+)/$', NestedResourceRoot.as_view()),
+ url(r'^resource/(?P<key>[0-9]+)/(?P<other>[A-Za-z]+)$', NestedResourceInstance.as_view()),
)
diff --git a/djangorestframework/utils/breadcrumbs.py b/djangorestframework/utils/breadcrumbs.py
index 1e604efc..0b043c78 100644
--- a/djangorestframework/utils/breadcrumbs.py
+++ b/djangorestframework/utils/breadcrumbs.py
@@ -4,6 +4,8 @@ from djangorestframework.utils.description import get_name
def get_breadcrumbs(url):
"""Given a url returns a list of breadcrumbs, which are each a tuple of (name, url)."""
+ from djangorestframework.views import View
+
def breadcrumbs_recursive(url, breadcrumbs_list):
"""Add tuples of (name, url) to the breadcrumbs list, progressively chomping off parts of the url."""
@@ -12,7 +14,8 @@ def get_breadcrumbs(url):
except:
pass
else:
- if callable(view):
+ # Check if this is a REST framework view, and if so add it to the breadcrumbs
+ if isinstance(getattr(view, 'cls_instance', None), View):
breadcrumbs_list.insert(0, (get_name(view), url))
if url == '':