diff options
| author | Erik Wickstrom | 2014-10-19 21:03:33 -0700 |
|---|---|---|
| committer | Erik Wickstrom | 2014-10-19 21:03:33 -0700 |
| commit | 12b677039d5485afa7bc913a6f56c4b107fbbe3f (patch) | |
| tree | 5e07a35988362d6b715dc0d42ccbac2252f53924 | |
| parent | 0951523300c627cbc52c992427069aac562ab70a (diff) | |
| download | django-rest-framework-12b677039d5485afa7bc913a6f56c4b107fbbe3f.tar.bz2 | |
Maintain order of views on router for api root view.
| -rw-r--r-- | rest_framework/routers.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/rest_framework/routers.py b/rest_framework/routers.py index f2d06211..9937566d 100644 --- a/rest_framework/routers.py +++ b/rest_framework/routers.py @@ -16,7 +16,7 @@ For example, you might have a `urls.py` that looks something like this: from __future__ import unicode_literals import itertools -from collections import namedtuple +from collections import namedtuple, OrderedDict from django.conf.urls import patterns, url from django.core.exceptions import ImproperlyConfigured from django.core.urlresolvers import NoReverseMatch @@ -277,7 +277,7 @@ class DefaultRouter(SimpleRouter): """ Return a view to use as the API root. """ - api_root_dict = {} + api_root_dict = OrderedDict() list_name = self.routes[0].name for prefix, viewset, basename in self.registry: api_root_dict[prefix] = list_name.format(basename=basename) @@ -286,7 +286,7 @@ class DefaultRouter(SimpleRouter): _ignore_model_permissions = True def get(self, request, *args, **kwargs): - ret = {} + ret = OrderedDict() for key, url_name in api_root_dict.items(): try: ret[key] = reverse( |
