Skip to content

Commit f13c0eb

Browse files
committed
Merge master
2 parents 8c91e7b + b733f85 commit f13c0eb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+862
-741
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*~
44
.*
55

6-
html/
6+
site/
77
htmlcov/
88
coverage/
99
build/

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ sudo: false
44

55
env:
66
- TOX_ENV=py27-flake8
7+
- TOX_ENV=py27-docs
78
- TOX_ENV=py34-django17
89
- TOX_ENV=py33-django17
910
- TOX_ENV=py32-django17

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ There are many great markdown editors that make working with the documentation r
101101

102102
## Building the documentation
103103

104-
To build the documentation, simply run the `mkdocs.py` script.
104+
To build the documentation, install MkDocs with `pip install mkdocs` and then run the following command.
105105

106-
./mkdocs.py
106+
mkdocs build
107107

108108
This will build the html output into the `html` directory.
109109

110-
You can build the documentation and open a preview in a browser window by using the `-p` flag.
110+
You can build the documentation and open a preview in a browser window by using the `serve` command.
111111

112-
./mkdocs.py -p
112+
mkdocs serve
113113

114114
## Language style
115115

docs/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
www.django-rest-framework.org

docs/api-guide/authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a class="github" href="authentication.py"></a>
1+
source: authentication.py
22

33
# Authentication
44

docs/api-guide/content-negotiation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a class="github" href="negotiation.py"></a>
1+
source: negotiation.py
22

33
# Content negotiation
44

@@ -29,7 +29,7 @@ The priorities for each of the given media types would be:
2929

3030
If the requested view was only configured with renderers for `YAML` and `HTML`, then REST framework would select whichever renderer was listed first in the `renderer_classes` list or `DEFAULT_RENDERER_CLASSES` setting.
3131

32-
For more information on the `HTTP Accept` header, see [RFC 2616][accept-header]
32+
For more information on the `HTTP Accept` header, see [RFC 2616][accept-header]
3333

3434
---
3535

@@ -62,7 +62,7 @@ request when selecting the appropriate parser or renderer.
6262
Select the first parser in the `.parser_classes` list.
6363
"""
6464
return parsers[0]
65-
65+
6666
def select_renderer(self, request, renderers, format_suffix):
6767
"""
6868
Select the first renderer in the `.renderer_classes` list.

docs/api-guide/exceptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a class="github" href="exceptions.py"></a>
1+
source: exceptions.py
22

33
# Exceptions
44

docs/api-guide/fields.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a class="github" href="fields.py"></a>
1+
source: fields.py
22

33
# Serializer fields
44

docs/api-guide/filtering.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a class="github" href="filters.py"></a>
1+
source: filters.py
22

33
# Filtering
44

@@ -26,7 +26,7 @@ For example:
2626

2727
class PurchaseList(generics.ListAPIView):
2828
serializer_class = PurchaseSerializer
29-
29+
3030
def get_queryset(self):
3131
"""
3232
This view should return a list of all the purchases
@@ -38,7 +38,7 @@ For example:
3838

3939
## Filtering against the URL
4040

41-
Another style of filtering might involve restricting the queryset based on some part of the URL.
41+
Another style of filtering might involve restricting the queryset based on some part of the URL.
4242

4343
For example if your URL config contained an entry like this:
4444

@@ -48,7 +48,7 @@ You could then write a view that returned a purchase queryset filtered by the us
4848

4949
class PurchaseList(generics.ListAPIView):
5050
serializer_class = PurchaseSerializer
51-
51+
5252
def get_queryset(self):
5353
"""
5454
This view should return a list of all the purchases for
@@ -57,15 +57,15 @@ You could then write a view that returned a purchase queryset filtered by the us
5757
username = self.kwargs['username']
5858
return Purchase.objects.filter(purchaser__username=username)
5959

60-
## Filtering against query parameters
60+
## Filtering against query parameters
6161

6262
A final example of filtering the initial queryset would be to determine the initial queryset based on query parameters in the url.
6363

6464
We can override `.get_queryset()` to deal with URLs such as `http://example.com/api/purchases?username=denvercoder9`, and filter the queryset only if the `username` parameter is included in the URL:
6565

6666
class PurchaseList(generics.ListAPIView):
6767
serializer_class = PurchaseSerializer
68-
68+
6969
def get_queryset(self):
7070
"""
7171
Optionally restricts the returned purchases to a given user,
@@ -113,7 +113,7 @@ For instance, given the previous example, and a product with an id of `4675`, th
113113
http://example.com/api/products/4675/?category=clothing&max_price=10.00
114114

115115
## Overriding the initial queryset
116-
116+
117117
Note that you can use both an overridden `.get_queryset()` and generic filtering together, and everything will work as expected. For example, if `Product` had a many-to-many relationship with `User`, named `purchase`, you might want to write a view like this:
118118

119119
class PurchasedProductsList(generics.ListAPIView):
@@ -124,7 +124,7 @@ Note that you can use both an overridden `.get_queryset()` and generic filtering
124124
model = Product
125125
serializer_class = ProductSerializer
126126
filter_class = ProductFilter
127-
127+
128128
def get_queryset(self):
129129
user = self.request.user
130130
return user.purchase_set.all()
@@ -135,7 +135,7 @@ Note that you can use both an overridden `.get_queryset()` and generic filtering
135135

136136
## DjangoFilterBackend
137137

138-
The `DjangoFilterBackend` class supports highly customizable field filtering, using the [django-filter package][django-filter].
138+
The `DjangoFilterBackend` class supports highly customizable field filtering, using the [django-filter package][django-filter].
139139

140140
To use REST framework's `DjangoFilterBackend`, first install `django-filter`.
141141

@@ -216,15 +216,15 @@ This is nice, but it exposes the Django's double underscore convention as part o
216216
And now you can execute:
217217

218218
http://example.com/api/products?manufacturer=foo
219-
219+
220220
For more details on using filter sets see the [django-filter documentation][django-filter-docs].
221221

222222
---
223223

224224
**Hints & Tips**
225225

226226
* By default filtering is not enabled. If you want to use `DjangoFilterBackend` remember to make sure it is installed by using the `'DEFAULT_FILTER_BACKENDS'` setting.
227-
* When using boolean fields, you should use the values `True` and `False` in the URL query parameters, rather than `0`, `1`, `true` or `false`. (The allowed boolean values are currently hardwired in Django's [NullBooleanSelect implementation][nullbooleanselect].)
227+
* When using boolean fields, you should use the values `True` and `False` in the URL query parameters, rather than `0`, `1`, `true` or `false`. (The allowed boolean values are currently hardwired in Django's [NullBooleanSelect implementation][nullbooleanselect].)
228228
* `django-filter` supports filtering across relationships, using Django's double-underscore syntax.
229229
* For Django 1.3 support, make sure to install `django-filter` version 0.5.4, as later versions drop support for 1.3.
230230

@@ -316,7 +316,7 @@ Typically you'd instead control this by setting `order_by` on the initial querys
316316
queryset = User.objects.all()
317317
serializer_class = UserSerializer
318318
filter_backends = (filters.OrderingFilter,)
319-
ordering = ('username',)
319+
ordering = ('username',)
320320

321321
The `ordering` attribute may be either a string or a list/tuple of strings.
322322

docs/api-guide/format-suffixes.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a class="github" href="urlpatterns.py"></a>
1+
source: urlpatterns.py
22

33
# Format suffixes
44

@@ -7,7 +7,7 @@ used all the time.
77
>
88
> &mdash; Roy Fielding, [REST discuss mailing list][cite]
99
10-
A common pattern for Web APIs is to use filename extensions on URLs to provide an endpoint for a given media type. For example, 'http://example.com/api/users.json' to serve a JSON representation.
10+
A common pattern for Web APIs is to use filename extensions on URLs to provide an endpoint for a given media type. For example, 'http://example.com/api/users.json' to serve a JSON representation.
1111

1212
Adding format-suffix patterns to each individual entry in the URLconf for your API is error-prone and non-DRY, so REST framework provides a shortcut to adding these patterns to your URLConf.
1313

@@ -21,7 +21,7 @@ Arguments:
2121

2222
* **urlpatterns**: Required. A URL pattern list.
2323
* **suffix_required**: Optional. A boolean indicating if suffixes in the URLs should be optional or mandatory. Defaults to `False`, meaning that suffixes are optional by default.
24-
* **allowed**: Optional. A list or tuple of valid format suffixes. If not provided, a wildcard format suffix pattern will be used.
24+
* **allowed**: Optional. A list or tuple of valid format suffixes. If not provided, a wildcard format suffix pattern will be used.
2525

2626
Example:
2727

@@ -33,7 +33,7 @@ Example:
3333
url(r'^comments/$', views.comment_list),
3434
url(r'^comments/(?P<pk>[0-9]+)/$', views.comment_detail)
3535
]
36-
36+
3737
urlpatterns = format_suffix_patterns(urlpatterns, allowed=['json', 'html'])
3838

3939
When using `format_suffix_patterns`, you must make sure to add the `'format'` keyword argument to the corresponding views. For example:
@@ -56,12 +56,12 @@ The name of the kwarg used may be modified by using the `FORMAT_SUFFIX_KWARG` se
5656
Also note that `format_suffix_patterns` does not support descending into `include` URL patterns.
5757

5858
---
59-
59+
6060
## Accept headers vs. format suffixes
6161

6262
There seems to be a view among some of the Web community that filename extensions are not a RESTful pattern, and that `HTTP Accept` headers should always be used instead.
6363

64-
It is actually a misconception. For example, take the following quote from Roy Fielding discussing the relative merits of query parameter media-type indicators vs. file extension media-type indicators:
64+
It is actually a misconception. For example, take the following quote from Roy Fielding discussing the relative merits of query parameter media-type indicators vs. file extension media-type indicators:
6565

6666
&ldquo;That's why I always prefer extensions. Neither choice has anything to do with REST.&rdquo; &mdash; Roy Fielding, [REST discuss mailing list][cite2]
6767

0 commit comments

Comments
 (0)