Commit 12b67703 by Erik Wickstrom

Maintain order of views on router for api root view.

parent 09515233
...@@ -16,7 +16,7 @@ For example, you might have a `urls.py` that looks something like this: ...@@ -16,7 +16,7 @@ For example, you might have a `urls.py` that looks something like this:
from __future__ import unicode_literals from __future__ import unicode_literals
import itertools import itertools
from collections import namedtuple from collections import namedtuple, OrderedDict
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
...@@ -277,7 +277,7 @@ class DefaultRouter(SimpleRouter): ...@@ -277,7 +277,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 = OrderedDict()
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 +286,7 @@ class DefaultRouter(SimpleRouter): ...@@ -286,7 +286,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 = OrderedDict()
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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment