Skip to content

Commit cf94201

Browse files
author
Emmanouil Konstantinidis
committed
Exclude Admin & DRFDocs Urls
1 parent 0a46f75 commit cf94201

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ Finally include the `drfdocs` urls in your `urls.py`:
3434

3535
urlpatterns = [
3636
...
37-
url(r'^docs/', include('drfdocs.urls', namespace='drfdocs')),
37+
url(r'^docs/', include('drfdocs.urls', app_name='drfdocs', namespace='drfdocs')),
3838
]

drfdocs/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ class DRFDocsView(TemplateView):
77

88
root_urlconf = __import__(settings.ROOT_URLCONF)
99
template_name = "drfdocs/home.html"
10+
EXCLUDED_APPS = ["admin", "drfdocs"]
1011
VIEW_NAMES = []
1112

1213
def get_all_view_names(self, urlpatterns):
1314
for pattern in urlpatterns:
1415
if isinstance(pattern, RegexURLResolver):
15-
self.get_all_view_names(pattern.url_patterns)
16+
if pattern.app_name not in self.EXCLUDED_APPS:
17+
self.get_all_view_names(pattern.url_patterns)
1618
elif isinstance(pattern, RegexURLPattern):
1719
view_name = pattern.callback.__name__
1820
self.VIEW_NAMES.append(view_name)

0 commit comments

Comments
 (0)