Ember data + django custom client or server


#1

Hi everyone, i’m new to emberjs and ember data. I’m coming from django. I see that ember data is not compatible with django rest framework and there are 2 solutions to make things work:

I’m working on a new project and i haven’t limitations or preconditions.

Which approach is better and why?

Thank you.


#2

Hi @cresg820, author of ember-django-adapter here. I’m a fan of client-side adapters primarily because I feel an API consumer should conform to the API server, not the other way around.

APIs generally provide documentation regarding their nature and ability, and then it is up to the consumer to use it to accomplish whatever task is desired. I often have multiple consumers for my API (website, mobile, etc.), and I don’t believe any one of them should dictate how my API works.

All that said, there are several things you can do when setting up your API using Django REST Framework that make it more Ember-friendly, but are not too invasive. Ember understands that there are several different API styles out there, and that’s why they explicitly make it possible to create adapters. This feature of Ember is encouraged and well documented.

However, if you do decide to try server-side adapters, you might also consider @gordon_c’s adapter: https://github.com/g-cassie/ember-drf


#3

Hi @cresg820, This came up recently on this thread and I offered some counter points to Dustin’s position. The only major point in favour of client side adapter is that you can support sideloading which for some data models can be really powerful.

The Ember adapter feels a bit more pluggable, but if you are experienced with DRF you might find (as I do) that doing the adapting on the DRF side is a lot more robust. My adapter project Dustin linked to is a more of a collection of modifications for DRF that all together make it work more or less out of the box with Ember.

On another note, I am just starting repo that I hope to one day use to show a basic django/ember app using my adapter (link). So far there is nothing in it but a project skeleton. I’m hoping to get some time soon to add some models and make a simple crud on the ember app.

@dustinfarris would be interesting if we could coordinate on a structure for a simple app (I was thinking something to do with cars) to demonstrate Ember/Django functionality and show what client adapter looks like vs. server adapter. Unfortunately my bandwidth is super limited right now but I think the django/ember community could really use a good example project with a solid explanatory blog post.


#4

Hi @gordon_c, @dustinfarris, thank for your answers.

@dustinfarris would be interesting if we could coordinate on a structure for a simple app (I was thinking something to do with cars) to demonstrate Ember/Django functionality and show what client adapter looks like vs. server adapter. Unfortunately my bandwidth is super limited right now but I think the django/ember community could really use a good example project with a solid explanatory blog post.

It is a very good idea. I’m coming from python/django and I had lot of problems to start.