@@ -81,20 +81,20 @@ From Source
81
81
$ git clone https://github.com/ngenworks/rest_framework_ember.git
82
82
$ cd rest_framework_ember && pip install -e .
83
83
84
-
84
+
85
85
-----
86
86
Usage
87
87
-----
88
88
89
89
90
- ``rest_framework_ember `` assumes you are using class-based views in Django
90
+ ``rest_framework_ember `` assumes you are using class-based views in Django
91
91
Rest Framework.
92
92
93
93
94
94
Settings
95
95
^^^^^^^^
96
96
97
- One can either add ``rest_framework_ember.parsers.EmberJSONParser `` and
97
+ One can either add ``rest_framework_ember.parsers.EmberJSONParser `` and
98
98
``rest_framework_ember.renderers.JSONRenderer `` to each ``ViewSet `` class, or
99
99
override ``settings.REST_FRAMEWORK ``::
100
100
@@ -119,7 +119,7 @@ override ``settings.REST_FRAMEWORK``::
119
119
120
120
121
121
If ``PAGINATE_BY `` is set the renderer will return a ``meta `` object with
122
- record count and the next and previous links. Django Rest Framework looks
122
+ record count and the next and previous links. Django Rest Framework looks
123
123
for the ``page `` GET parameter by default allowing you to make requests for
124
124
subsets of the data with ``this.store.find('identity', {page: 2}); ``.
125
125
@@ -142,5 +142,29 @@ the ``resource_name`` property is required on the class.::
142
142
permission_classes = (permissions.IsAuthenticated, )
143
143
144
144
145
+ Managing the trailing slash
146
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
147
+
148
+ By default Django expects a trailing slash on urls and will 301 redirect any
149
+ requests lacking a trailing slash. You can change the server side by
150
+ instantiating the Django REST Framework's router like so:
151
+
152
+ router = routers.SimpleRouter(trailing_slash=False)
145
153
154
+ If you aren't using SimpleRouter you can instead set APPEND_SLASH = False
155
+ in Django's settings.py file and modify url pattern regex to match routes
156
+ without a trailing slash.
157
+
158
+ If you prefer to make the change on the client side then add an
159
+ application adapter to your Ember app and override the buildURL method:
160
+
161
+ App.ApplicationAdapter = DS.RESTAdapter.extend({
162
+ buildURL: function() {
163
+ var url = this._super.apply(this, arguments);
164
+ if (url.charAt(url.length -1) !== '/') {
165
+ url += '/';
166
+ }
167
+ return url;
168
+ }
169
+ });
146
170
0 commit comments