aboutsummaryrefslogtreecommitdiffstats
path: root/docs/examples/blogpost.rst
blob: 07f7cbc56af4a03802a9806a350bf43e9cc38404 (plain)
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
.. _blogposts:

Blog Posts API
==============

* http://api.django-rest-framework.org/blog-post/

The models
----------

``models.py``

.. include:: ../../examples/blogpost/models.py
    :literal:

URL configuration
-----------------

``urls.py``

.. include:: ../../examples/blogpost/urls.py
    :literal:

Creating the resources
----------------------

Once we have some existing models there's very little we need to do to create the corresponding resources.  We simply create a base resource and an instance resource for each model we're working with.
django-rest-framework will provide the default operations on the resources all the usual input validation that Django's models can give us for free.

``views.py``

.. include:: ../../examples/blogpost/views.py
    :literal: