Deploying Ember with Django


#1

Hi all, I have recently finished my first round of learning both Ember and Django. I have been able to create small tutorial applications in both of them individually. Now I am trying to combine both of them.

My approach is to create an API using Django REST Adapter and consume it in Ember using the available RESTAdapter. It would be great if someone can help me with the following questions: Where do I put my Ember application files and how can I link them with Django? Is it necessary to create models for common objects on both ends(Django and Ember)? Also, is there any Django-Ember starter kit available which I can use to build upon? (Similar to https://github.com/emberjs/ember-rails ) Thanks!!


Creating a basic ember.js + django app
#2

@toranb may be the correct guy to respond


#3

@sahrizv @stefan I can help you get started but I need to ask a few questions first

1.) can you leverage something like node.js / npm to build the assets with grunt or do you need something in pure python?

2.) what version of django can you use for this project?

3.) assuming the answer to #2 is 1.3 / 1.4 / 1.5 -what REST api framework will you layer on top of core django? do you have a preference? I think the major 2 in the wild are

http://django-rest-framework.org/

http://tastypieapi.org/

4.) do you want to start out with vanilla models or would you need a full blow object store for the javascript application (something like ember-data or ember-model) ?

here is my generic answer w/out knowing any of the above.

First I would scaffold your django models like you would in any django app. Next I would pip install the django-rest-framework (my REST api of choice). Then I would learn grunt to build a client side build step that could compile your handlebars templates (using npm) Finally I would write a really simple ember app that uses a single model from the REST api (running grunt locally to see it all work).

If you want to pair up sometime next week ping my gmail w/ a day and time that works for you

toranb [at] gmail


#4

@sahrizv I just threw together a quick django + django-rest-framework + ember + grunt example if you want to play with it yourself


Division of responsibilities between Django and Ember
#5

Hi Toran!! First of all a big thank you for such a helpful reply from you. It really makes me happy. I just saw the sample application you have posted and it is exactly what I was looking for. :slight_smile: I had already seen your file uploader example yesterday before asking this question but just wasn’t sure what is the minimum required setup. Now I know it, and in case of doubt I can compare the two. I’ll answer the questions below.

1.) can you leverage something like node.js / npm to build the assets with grunt or do you need something in pure python?

A: Yes. Although I have not used grunt yet, I am very keen on learning it, along with Yeoman.

2.) what version of django can you use for this project?

A: I am using 1.5

3.) assuming the answer to #2 is 1.3 / 1.4 / 1.5 -what REST api framework will you layer on top of core django? do you have a preference?

A: I have decided to use Django REST Framework. I have built a test API on my Django models as a learning exercise, few days ago.

4.) do you want to start out with vanilla models or would you need a full blow object store for the javascript application (something like ember-data or ember-model) ?

A: Since I am learning ember, I would want to try out both these approaches so that I can make an informed decision when the time comes. I am aware of the unstability of ember-data but still wanted to use it( or maybe the EPF)

“here is my generic answer w/out knowing any of the above. First I would scaffold your django models like you would in any django app. Next I would pip install the django-rest-framework (my REST api of choice). Then I would learn grunt to build a client side build step that could compile your handlebars templates (using npm) Finally I would write a really simple ember app that uses a single model from the REST api (running grunt locally to see it all work).”

I would follow your advice and revert to you in case of problems.

"If you want to pair up sometime next week ping my gmail w/ a day and time that works for you

toranb [at] gmail"

That is extremely generous and helpful of you. I really do not want to take up your precious time with on this, especially that you have given me all that is needed to get started. Moreover, I would like to save your offer for a time when I am in more complex situation.(If that’s all right with you :smiley: )


#6

Just what I needed!! :slight_smile:


#7

Found @toranb and @escalant3 adapters usefull. But if you want to use the built-in rest adapter, try django-ember-rest with component.


#8

Would this now be the best project to utilise for Django and Ember now https://github.com/noirbizarre/django-ember ?

And moving to ember 2.0 or if I start there as I am just starting with ember now would this still be relevant?