Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blacklocus/angular-django-rest-resource
An AngularJS module that provides a resource-generation service similar to ngResource, but optimized for the Django REST Framework.
https://github.com/blacklocus/angular-django-rest-resource
Last synced: 3 months ago
JSON representation
An AngularJS module that provides a resource-generation service similar to ngResource, but optimized for the Django REST Framework.
- Host: GitHub
- URL: https://github.com/blacklocus/angular-django-rest-resource
- Owner: blacklocus
- License: other
- Created: 2013-05-06T17:19:36.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-01-30T21:32:18.000Z (almost 8 years ago)
- Last Synced: 2024-08-18T01:02:33.056Z (4 months ago)
- Language: Python
- Size: 339 KB
- Stars: 251
- Watchers: 27
- Forks: 29
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
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:
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](http://docs.angularjs.org/api/ngResource.$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.txt3. 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/`.