mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-14 05:36:50 +03:00
Fix breadcrumb view names
This commit is contained in:
parent
556b4bbba9
commit
02b6836ee8
|
@ -8,8 +8,11 @@ def get_breadcrumbs(url):
|
||||||
tuple of (name, url).
|
tuple of (name, url).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from rest_framework.settings import api_settings
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
|
view_name_func = api_settings.VIEW_NAME_FUNCTION
|
||||||
|
|
||||||
def breadcrumbs_recursive(url, breadcrumbs_list, prefix, seen):
|
def breadcrumbs_recursive(url, breadcrumbs_list, prefix, seen):
|
||||||
"""
|
"""
|
||||||
Add tuples of (name, url) to the breadcrumbs list,
|
Add tuples of (name, url) to the breadcrumbs list,
|
||||||
|
@ -28,8 +31,8 @@ def get_breadcrumbs(url):
|
||||||
# Don't list the same view twice in a row.
|
# Don't list the same view twice in a row.
|
||||||
# Probably an optional trailing slash.
|
# Probably an optional trailing slash.
|
||||||
if not seen or seen[-1] != view:
|
if not seen or seen[-1] != view:
|
||||||
instance = view.cls()
|
suffix = getattr(view, 'suffix', None)
|
||||||
name = instance.get_view_name()
|
name = view_name_func(cls, suffix)
|
||||||
breadcrumbs_list.insert(0, (name, prefix + url))
|
breadcrumbs_list.insert(0, (name, prefix + url))
|
||||||
seen.append(view)
|
seen.append(view)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user