Ember.js + Django

Becd166a81dc51c0009f602d175d0cc8?s=47 José Padilla
September 26, 2013

Ember.js + Django

Quick deck about how easy it was to switch an Ember.js app from using localStorage adapter to using an adapter for Django REST Framework.

Becd166a81dc51c0009f602d175d0cc8?s=128

José Padilla

September 26, 2013
Tweet

Transcript

  1. E b r. + D B : J P

  2. twitter.com/jpadilla_ github.com/jpadilla jpadilla.com

  3. Co-founder at

  4. Get a $5 Amazon gift card and up to 1-year

    of Blimp PRO for free
  5. bit.ly/tryblimp Try Get 1 free month of Blimp Pro.

  6. None
  7. None
  8. None
  9. None
  10. localStorage

  11. module.exports = App.ApplicationAdapter = DS.LSAdapter; https://github.com/rpflorence/ember-localstorage-adapter

  12. Chrome Extension bit.ly/poe-chrome Demo bit.ly/poe-demo

  13. None
  14. None
  15. from django.db import models class Document(models.Model): title = models.CharField(max_length=255) body

    = models.TextField() created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __unicode__(self): return self.title
  16. from django.conf.urls.defaults import url, patterns, include from rest_framework import viewsets,

    routers from apps.documents.models import Document # ViewSets define the view behavior. class DocumentViewSet(viewsets.ModelViewSet): model = Document # Routers provide an easy way of automatically determining the URL conf router = routers.DefaultRouter() router.register(r'documents', DocumentViewSet) urlpatterns = patterns('', url(r'^', include(router.urls)) )
  17. MIDDLEWARE_CLASSES += ( 'corsheaders.middleware.CorsMiddleware', ) INSTALLED_APPS += ( 'corsheaders', 'rest_framework',

    'apps.documents', ) # django-cors-headers CORS_ORIGIN_WHITELIST = ( 'localhost:3333', )
  18. DS.DjangoRESTAdapter.reopen({ host: "http://localhost:8000" }); module.exports = App.ApplicationAdapter = DS.DjangoRESTAdapter; https://github.com/toranb/ember-data-django-rest-

    adapter/tree/ember1.0
  19. Thank you.