{ "info": { "author": "Zach Mathew", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Topic :: Software Development" ], "description": "===============\ndjango-backbone\n===============\n\n\nOverview\n--------\nThis app provides a Backbone.js compatible REST API for your models. It follows the Django admin pattern of extending, overriding and registering; and provides an extendable class based view for customization.\n\nThis way you can have quick, out-of-the-box functionality or you can override any method or variable to customize things to your liking.\n\nFor example:\n::\n\n # fooapp/backbone_api.py\n import backbone\n from fooapp.models import Foo\n\n class FooAPIView(backbone.views.BackboneAPIView):\n model = Foo\n display_fields = ('title', 'description')\n ordering = ('creation_date', 'id')\n\n backbone.site.register(FooAPIView)\n\n\nMore advanced customization can be accomplished by hooking into methods on the inherited class - which itself is a class based view. For example:\n::\n\n ...\n\n class FooAPIView(backbone.views.BackboneAPIView):\n model = Foo\n display_fields = ('title', 'description',)\n ordering = ('creation_date', 'id')\n\n def post(self, request):\n return HttpResponseForbidden('No adding allowed!')\n\n def queryset(self, request):\n # Only return \"active\" objects\n return Foo.objects.filter(is_active=True).order_by('-id')\n\n def has_delete_permission(request, obj):\n return request.user.is_staff # Only staff can delete objects\n ...\n\n\nFeatures\n--------\n* Automatically generates a JSON REST API for your models that works nicely with Backbone.js.\n* API based on class based views and model forms allowing for fine-grained customization and extensibility.\n* Customizable permission restrictions. By default it uses ``django.contrib.auth`` authentication and permissions (similar to Django admin).\n\n\nUsage\n-----\n#. Create a ``backbone_api.py`` file in your app folder and register your API definitions by subclassing ``backbone.views.BackboneAPIView``.\n ::\n\n # fooapp/backbone_api.py\n import backbone\n from fooapp.models import Foo\n\n class FooAPIView(backbone.views.BackboneAPIView):\n model = Foo\n display_fields = ('title', 'description')\n ordering = ('creation_date', 'id')\n\n backbone.site.register(FooAPIView)\n\n See section on 'BackboneAPIView Options' for a full list of options available.\n\n#. In your Javascript collection/model definitions, set the ``url``/``urlRoot`` to point to the ``django-backbone`` API:\n ::\n\n // Assuming you have a Backbone model called 'Foo' and a collection 'FooCollection'\n Foo.prototype.urlRoot = \"{% url 'backbone:fooapp_foo' %}\";\n FooCollection.prototype.url = \"{% url 'backbone:fooapp_foo' %}\";\n\n See section on 'URL reversing' below for details on the url naming.\n\n#. (Optional) If your have csrf protection turned on, you'll need to modify the Backbone.sync command to send the csrf token:\n ::\n\n \n\n#. That's it. You should now be able to perform ``fetch()``, ``save()``, etc. on your Backbone collections and models.\n\n\nPermissions\n'''''''''''\n\nBy default, ``django-backbone`` prevents add, update or delete requests unless the user is logged in and has the ``can_add``, ``can_change`` or ``can_delete`` permission (respectively). This follows the permissions used in the Django admin, with one exception - **read access is permitted** publicly on all registered models.\n\nThis can be changed by overriding the appropriate permission hooks (see section '``BackboneAPIView`` Options').\n\n\n``BackboneAPIView`` Options\n'''''''''''''''''''''''''''\n\nPlease check out the source code of the class ``backbone.views.BackboneAPIView`` for the full list of hooks. The methods are documented by their docstrings.\n\nHere are some basic options that you can customize:\n\n* ``model``: The model to be used for this API definition\n* ``display_fields``: Fields to return for read (GET) requests,\n* ``fields``: Fields to allow when adding (POST) or editing (PUT) objects.\n* ``form``: The form class to be used for adding or editing objects.\n* ``ordering``: Ordering used when retrieving the collection\n* ``paginate_by``: The max number of objects per page (enables use of the ``page`` GET parameter).\n\n\nReversing the API urls\n''''''''''''''''''''''\n\nThe following named URL patterns are provided for all models that are registered:\n\n* Collection URL: ``backbone:_`` (reverses to ``///``)\n* Model URL: ``backbone:__detail`` (reverses to ``///``)\n\nYou can change the ```` in the url (and url name) by specifying the ``url_slug`` attribute on the ``BackboneView`` class (just be sure it doesn't collide with another view).\n\n\n\nInstallation\n------------\nNote: ``django-backbone`` requires Django 1.3 or higher.\n\n#. Add ``backbone`` to ``INSTALLED_APPS`` in your settings file.\n#. Hook in the urls and call ``backbone.autodiscover()`` (which will find all ``backbone_api.py`` files in your apps):\n ::\n\n # urls.py\n\n import backbone\n backbone.autodiscover()\n\n urlpatterns += patterns('',\n (r'^backbone/', include(backbone.site.urls)),\n )\n\n\n\nRunning the tests\n-----------------\n::\n\n # For Django 1.6+\n ./manage.py test backbone.tests --settings=backbone.tests.settings\n\n # For Django < 1.6\n ./manage.py test tests --settings=backbone.tests.settings\n\n\n\nAlternatives/Inspiration\n------------------------\nThis app borrows concepts and patterns from other open source Django/Backbone integration apps. It's worth having a look at them as they may be better suited depending on your use case:\n\n* `djangbone `_: Light weight, simliar concept using class based views.\n* `backbone-tastypie `_: A little heavier as it uses `django-tastypie `_ which can provide some powerful API features such as throttling and caching.\n\n\nLicense\n-------\nThis app is licensed under the BSD license. See the LICENSE file for details.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/zmathew/django-backbone", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-backbone", "package_url": "https://pypi.org/project/django-backbone/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-backbone/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/zmathew/django-backbone" }, "release_url": "https://pypi.org/project/django-backbone/0.3.2/", "requires_dist": null, "requires_python": null, "summary": "Provides a Backbone.js compatible REST API for your models using Django Admin style registration.", "version": "0.3.2" }, "last_serial": 2601048, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "d2292a7f06c7cf63abc0e3bc10b97fa4", "sha256": "bd251caf3c34098019a3317ff81d0bd9a97b134074b25e0f44e92b23b83aabde" }, "downloads": -1, "filename": "django-backbone-0.1.0.tar.gz", "has_sig": false, "md5_digest": "d2292a7f06c7cf63abc0e3bc10b97fa4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11586, "upload_time": "2012-08-30T19:48:52", "url": "https://files.pythonhosted.org/packages/2a/7e/9d98754c3dd0bb52441b55d28d26c51e020761219df0e9d5ab17cfe606cb/django-backbone-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "a297379c58389ab71e84aea7fd566568", "sha256": "6998961b74fb86b70f8c02b35ee7a21494a95a590559ead23cf45788e68cba2a" }, "downloads": -1, "filename": "django-backbone-0.2.0.tar.gz", "has_sig": false, "md5_digest": "a297379c58389ab71e84aea7fd566568", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11526, "upload_time": "2012-08-30T19:49:56", "url": "https://files.pythonhosted.org/packages/53/c5/e66e6c482473301d864a8ea9dda9c9cb23bef0b30298128c933ba6025f77/django-backbone-0.2.0.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "e18f65d38785f95b0ca6c58fe4a28fde", "sha256": "6cb5eb8b186bdc420e86079c877e6fcae6428f9fc9f1a2f812385d3b95ad5f9d" }, "downloads": -1, "filename": "django-backbone-0.2.2.tar.gz", "has_sig": false, "md5_digest": "e18f65d38785f95b0ca6c58fe4a28fde", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12367, "upload_time": "2012-09-27T15:42:37", "url": "https://files.pythonhosted.org/packages/b8/58/3756a5fab8e252f0a596543812d9d5ada806da0585695d0712f530849803/django-backbone-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "68050abe4fa2d1515f1989b60a629a32", "sha256": "2ae3c80aa0a2cc2294c17ed5a60b862d9f60c34a112e4504d23136366235d3b9" }, "downloads": -1, "filename": "django-backbone-0.2.3.tar.gz", "has_sig": false, "md5_digest": "68050abe4fa2d1515f1989b60a629a32", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12568, "upload_time": "2012-11-08T02:21:44", "url": "https://files.pythonhosted.org/packages/91/18/a265d0518d1038a16d9770783c38e02051cb4a3d2b0d1bb5822bfdd1166d/django-backbone-0.2.3.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "e4ae09374df4390c5e97b7cc74741fb5", "sha256": "607e8e1639e701aa86dee3f7dba6d174fd095a6b353b9fee6c0bd41e60824a86" }, "downloads": -1, "filename": "django-backbone-0.3.0.tar.gz", "has_sig": false, "md5_digest": "e4ae09374df4390c5e97b7cc74741fb5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12416, "upload_time": "2013-04-02T15:37:05", "url": "https://files.pythonhosted.org/packages/f3/0f/90425dd398c43326f33191ddbbe0a015e46cac568ab4edc642b3449b8fdb/django-backbone-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "8ecd58e33a73b0a95ae3eb0844f1a3cd", "sha256": "74debcb3fad25bee4df39605f3b76637a066d3f60fa5912935e324d61e5420b8" }, "downloads": -1, "filename": "django-backbone-0.3.1.tar.gz", "has_sig": false, "md5_digest": "8ecd58e33a73b0a95ae3eb0844f1a3cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13193, "upload_time": "2013-09-18T14:59:53", "url": "https://files.pythonhosted.org/packages/8c/82/861123d7f36ead47754114f9a73ac6f6cee485834645f1e524e0f8ad8c36/django-backbone-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "8f522bf92e6712dce701b4bbc0a8455f", "sha256": "6c3fad880560fe4b6530e8a85caefdb03df53943f6043629991eb1582b661338" }, "downloads": -1, "filename": "django-backbone-0.3.2.tar.gz", "has_sig": false, "md5_digest": "8f522bf92e6712dce701b4bbc0a8455f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13062, "upload_time": "2014-07-29T01:52:47", "url": "https://files.pythonhosted.org/packages/16/9d/fa48753c09b2628e55d987b1a9c48e0273dcb49273dec5eae8d9cf5d4676/django-backbone-0.3.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "8f522bf92e6712dce701b4bbc0a8455f", "sha256": "6c3fad880560fe4b6530e8a85caefdb03df53943f6043629991eb1582b661338" }, "downloads": -1, "filename": "django-backbone-0.3.2.tar.gz", "has_sig": false, "md5_digest": "8f522bf92e6712dce701b4bbc0a8455f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13062, "upload_time": "2014-07-29T01:52:47", "url": "https://files.pythonhosted.org/packages/16/9d/fa48753c09b2628e55d987b1a9c48e0273dcb49273dec5eae8d9cf5d4676/django-backbone-0.3.2.tar.gz" } ] }