Giter VIP home page Giter VIP logo

angular-django-rest-resource's Introduction

angular-django-rest-resource

An AngularJS module that provides a resource-generation service similar to ngResource, but optimized for the Django REST Framework. The biggest features:

  • Trailing slashes allowed in the resource URLs per the Django community norm.
  • The isArray methods like query allow for paginated responses. The pages will be streamed into the promise object.

Installation

Download angular-django-rest-resource.js and put it in your project. You may also do it the bower way:

bower install angular-django-rest-resource

Usage

Do this somewhere in your application HTML:

<script src="angular-django-rest-resource.js"></script>

Add this AngularJS module as a dependency to your AngularJS application:

angular.module('app', [..., 'djangoRESTResources']);

(where 'app' is whatever you've named your AngularJS application).

In your controllers and anything that needs to interact with the Django REST Framework services, inject the djResource service. Then you can create class-like objects that represent (and interact with) your Django REST Framework resources:

var Poll = djResource('/polls/:pollId/', {pollId:'@id'});

var myPoll = Poll.get({pollId:86}, function() {
    myPoll.readByUser = true;
    myPoll.$save();
});

For complete API, consider the documentation for $resource, as this module follows the API quite closely.

Launching The Testing and Demonstration App

This is a work in progress, but it gives some hints on usage in a real world scenario.

  1. Create a Python virtualenv.

  2. Install the dependencies:

     cd test
     pip install -r requirements.txt
    
  3. Set up the database and fixtures (if first time use).

     python manage.py syncdb
    
  4. Run the server:

     python manage.py runserver
    
  5. Point web browser to http://localhost:8000/.

angular-django-rest-resource's People

Contributors

charliefrantowski avatar georgewhewell avatar j0hnsmith avatar justintarthur avatar kosz85 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.