File: index.rst

package info (click to toggle)
django-tastypie 0.9.10-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 1,020 kB
  • sloc: python: 6,530; makefile: 78; sh: 45
file content (96 lines) | stat: -rw-r--r-- 2,565 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Welcome to Tastypie!
====================

Tastypie is an webservice API framework for Django. It provides a convenient,
yet powerful and highly customizable, abstraction for creating REST-style
interfaces.

.. toctree::
   :maxdepth: 2
   
   tutorial
   interacting
   settings
   non_orm_data_sources
   
   resources
   api
   fields
   caching
   validation
   authentication_authorization
   serialization
   throttling
   
   cookbook
   debugging
   who_uses


Getting Help
============

There are two primary ways of getting help. We have a `mailing list`_ hosted at
Google (http://groups.google.com/group/django-tastypie/) and an IRC channel
(`#tastypie on irc.freenode.net`_) to get help, want to bounce idea or
generally shoot the breeze.

.. _`mailing list`: http://groups.google.com/group/django-tastypie/
.. _#tastypie on irc.freenode.net: irc://irc.freenode.net/tastypie


Quick Start
===========

1. Add ``tastypie`` to ``INSTALLED_APPS``.
2. Create an ``api`` directory in your app with a bare ``__init__.py``.
3. Create an ``<my_app>/api/resources.py`` file and place the following in it::

    from tastypie.resources import ModelResource
    from my_app.models import MyModel
    
    
    class MyModelResource(ModelResource):
        class Meta:
            queryset = MyModel.objects.all()
            allowed_methods = ['get']

4. In your root URLconf, add the following code (around where the admin code might be)::
    
    from tastypie.api import Api
    from my_app.api.resources import MyModelResource
    
    v1_api = Api(api_name='v1')
    v1_api.register(MyModelResource())
    
    urlpatterns = patterns('',
      # ...more URLconf bits here...
      # Then add:
      (r'^api/', include(v1_api.urls)),
    )

5. Hit http://localhost:8000/api/v1/?format=json in your browser!


Requirements
============

Tastypie requires the following modules. If you use Pip_, you can install
the necessary bits via the included ``requirements.txt``:

* Python 2.4+
* Django 1.0+
* mimeparse 0.1.3+ (http://code.google.com/p/mimeparse/)

  * Older versions will work, but their behavior on JSON/JSONP is a touch wonky.

* dateutil (http://labix.org/python-dateutil)
* lxml (http://codespeak.net/lxml/) if using the XML serializer
* pyyaml (http://pyyaml.org/) if using the YAML serializer

If you choose to use Python 2.4, be warned that you will also need to grab the
following modules:

* uuid (present in 2.5+, downloadable from http://pypi.python.org/pypi/uuid/) if using the ``ApiKey`` authentication

.. _Pip: http://pip.openplans.org/