Integrating ember-cli dist output into a django application


#1

Hi folks,

My background is that I’ve been mostly on JAVA and Vaadin stack for quite some time but have done work in the past with jQuery, prototype AJAX Apps. After doing some research, I’m planning to write my next app using Ember CLI, Ember-Data. Django and Django Rest Framework.

As far as my deployment is concerned, I would like to simplify and secure my deployment by having everything in 1 Django app, rather than having a static web ember app calling my django REST Services. For me this will simplify my deployment since all I have to do is deploy a django app and make it more secure because I can:

  • Use Django Authentication to protect entry into the Ember App.
  • Use Django CSRF Token Auth for protection.
  • Use Django Authentication on my REST endpoints also.
  • Use Django default REST framework protection to make sure that my back end services are being called from the same domain and not from elsewhere

That being the case, I seem to be having some trouble when I try either of the following:

  1. just copy the contents of the dist folder into my static folder for django and refer to those.
  2. Copy them as different django templates and include them in a main template.
  3. keep them in my static folder and refer to them as source javascript files from a template

I keep getting this error define is not defined

However, when I copy and paste these contents at the root of my apache2 web server, the app runs perfectly.

I would like to understand?

  1. What is the best way to deploy the output of an ember-CLI app inside of a django web app?
  2. Is there a better way to do what I’m trying to do and still get all the security benefits and simple deployment I’m trying to get? I find this deployment model simple because all I depend on is deploying a django app. I don’t have a situation where back end development is done and deployed by a different party than the front end development.
  3. In my case would it make sense for me to not use Ember CLI but just use Ember JS and do ember JS deployment inside of my Django app through django templates using the traditional way Ember is used as per the Ember JS videos?

I would appreciate any advice on the above questions.

Amarish


#2

Looks like I’m going to be better off going with Rails on the server side. It seems to have a lot of support for ember.


#3

Have a look at the djember [1] project. The cookiecutter project works out of the box and brings everything you need to get started.

It supports django session auth but is easy extensible to use Token auth. Both using ember-simple-auth under the hood.

It also brings dynamic model generation so that you can reuse your django models directly in ember without redefining them.

[1] http://djembersample.pythonanywhere.com/