Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ember.js + Django

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.

José Padilla

September 26, 2013
Tweet

More Decks by José Padilla

Other Decks in Programming

Transcript

  1. 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
  2. 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)) )
  3. MIDDLEWARE_CLASSES += ( 'corsheaders.middleware.CorsMiddleware', ) INSTALLED_APPS += ( 'corsheaders', 'rest_framework',

    'apps.documents', ) # django-cors-headers CORS_ORIGIN_WHITELIST = ( 'localhost:3333', )