mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
Merge pull request #1969 from erikcw/ordered
Maintain order of views on router for api root view.
This commit is contained in:
commit
4ad4fca6ce
|
@ -20,6 +20,7 @@ from collections import namedtuple
|
||||||
from django.conf.urls import patterns, url
|
from django.conf.urls import patterns, url
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.urlresolvers import NoReverseMatch
|
from django.core.urlresolvers import NoReverseMatch
|
||||||
|
from django.utils.datastructures import SortedDict
|
||||||
from rest_framework import views
|
from rest_framework import views
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.reverse import reverse
|
from rest_framework.reverse import reverse
|
||||||
|
@ -277,7 +278,7 @@ class DefaultRouter(SimpleRouter):
|
||||||
"""
|
"""
|
||||||
Return a view to use as the API root.
|
Return a view to use as the API root.
|
||||||
"""
|
"""
|
||||||
api_root_dict = {}
|
api_root_dict = SortedDict()
|
||||||
list_name = self.routes[0].name
|
list_name = self.routes[0].name
|
||||||
for prefix, viewset, basename in self.registry:
|
for prefix, viewset, basename in self.registry:
|
||||||
api_root_dict[prefix] = list_name.format(basename=basename)
|
api_root_dict[prefix] = list_name.format(basename=basename)
|
||||||
|
@ -286,7 +287,7 @@ class DefaultRouter(SimpleRouter):
|
||||||
_ignore_model_permissions = True
|
_ignore_model_permissions = True
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
ret = {}
|
ret = SortedDict()
|
||||||
for key, url_name in api_root_dict.items():
|
for key, url_name in api_root_dict.items():
|
||||||
try:
|
try:
|
||||||
ret[key] = reverse(
|
ret[key] = reverse(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user