11===============================
2- Ember and Django Rest Framework
2+ Ember Data and Django Rest Framework
33===============================
44
5- EmberJS is extremely opinionated on how JSON REST requests and responses
6- should look. Going against the grain can lead to frustrated Javascript
7- developers.
5+ The default Ember Data REST Adapter conventions differ from the default
6+ Django Rest Framework JSON request and response format. Instead of adding
7+ a Django specific adapter to Ember Data we use this adapter in Django to
8+ output and accept JSON in the format the Ember Data REST Adapter expects.
89
910By default, Django REST Framework will produce a response like::
1011
1112 {
12- "id": 1,
13- "username": "john",
14- "full_name": "John Coltrane"
13+ "count": 20,
14+ "next": "http://example.com/api/1.0/identities/?page=2",
15+ "previous": null,
16+ "results": [
17+ {
18+ "id": 1,
19+ "username": "john",
20+ "full_name": "John Coltrane"
21+ },
22+ {
23+ ...
24+ }
25+ ]
1526 }
1627
1728
18- However, if this is an ``identity `` model in EmberJS, Ember expects a
19- response to look like the following::
29+ However, for an ``identity `` model in EmberJS, the Ember Data REST Adapter
30+ expects a response to look like the following::
2031
2132 {
22- "identity": {
23- "id": 1,
24- "username": "john",
25- "full_name": "John Coltrane"
33+ "identity": [
34+ {
35+ "id": 1,
36+ "username": "john",
37+ "full_name": "John Coltrane"
38+ },
39+ {
40+ ...
41+ }
42+ ],
43+ "meta": {
44+ "count": 20,
45+ "next": "http://example.com/api/1.0/identities/?page=2",
46+ "previous": null
2647 }
2748 }
2849
@@ -61,6 +82,7 @@ override ``settings.REST_FRAMEWORK``::
6182
6283
6384 REST_FRAMEWORK = {
85+ 'PAGINATE_BY': 10,
6486 'DEFAULT_PARSER_CLASSES': (
6587 'rest_framework_ember.parsers.EmberJSONParser',
6688 'rest_framework.parsers.FormParser',
@@ -74,6 +96,10 @@ override ``settings.REST_FRAMEWORK``::
7496 }
7597
7698
99+ If PAGINATE_BY is included the renderer will return a ``meta `` object with
100+ record count and the next and previous links.
101+
102+
77103resource_name property
78104^^^^^^^^^^^^^^^^^^^^^^
79105
0 commit comments