mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 22:04:48 +03:00
Use '.callback' property instead of private attributes when inspecting urlpatterns
This commit is contained in:
parent
46f2ec49da
commit
9d1ee6f896
|
@ -60,17 +60,21 @@ def distinct(queryset, base):
|
|||
|
||||
def get_names_and_managers(options):
|
||||
if django.VERSION >= (1, 10):
|
||||
# Django 1.10 onwards provides a `.managers` property on the Options.
|
||||
return [
|
||||
(manager.name, manager)
|
||||
for manager
|
||||
in options.managers
|
||||
]
|
||||
# For Django 1.8 and 1.9, use the three-tuple information provided
|
||||
# by .concrete_managers and .abstract_managers
|
||||
return [
|
||||
(manager_info[1], manager_info[2])
|
||||
for manager_info
|
||||
in (options.concrete_managers + options.abstract_managers)
|
||||
]
|
||||
|
||||
|
||||
# contrib.postgres only supported from 1.8 onwards.
|
||||
try:
|
||||
from django.contrib.postgres import fields as postgres_fields
|
||||
|
|
|
@ -24,7 +24,7 @@ def apply_suffix_patterns(urlpatterns, suffix_pattern, suffix_required):
|
|||
else:
|
||||
# Regular URL pattern
|
||||
regex = urlpattern.regex.pattern.rstrip('$').rstrip('/') + suffix_pattern
|
||||
view = urlpattern._callback or urlpattern._callback_str
|
||||
view = urlpattern.callback
|
||||
kwargs = urlpattern.default_args
|
||||
name = urlpattern.name
|
||||
# Add in both the existing and the new urlpattern
|
||||
|
|
Loading…
Reference in New Issue
Block a user