Skip to content

Commit 81870b6

Browse files
committed
Merge pull request #2 from tomchristie/master
Merge upstream
2 parents 7165496 + d1fe61c commit 81870b6

Some content is hidden

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

79 files changed

+2217
-5574
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: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
11
language: python
22

3-
python: 2.7
4-
53
sudo: false
64

75
env:
8-
- TOX_ENV=flake8
9-
- TOX_ENV=py3.4-django1.7
10-
- TOX_ENV=py3.3-django1.7
11-
- TOX_ENV=py3.2-django1.7
12-
- TOX_ENV=py2.7-django1.7
13-
- TOX_ENV=py3.4-django1.6
14-
- TOX_ENV=py3.3-django1.6
15-
- TOX_ENV=py3.2-django1.6
16-
- TOX_ENV=py2.7-django1.6
17-
- TOX_ENV=py2.6-django1.6
18-
- TOX_ENV=py3.4-django1.5
19-
- TOX_ENV=py3.3-django1.5
20-
- TOX_ENV=py3.2-django1.5
21-
- TOX_ENV=py2.7-django1.5
22-
- TOX_ENV=py2.6-django1.5
23-
- TOX_ENV=py2.7-django1.4
24-
- TOX_ENV=py2.6-django1.4
25-
- TOX_ENV=py3.4-djangomaster
26-
- TOX_ENV=py3.3-djangomaster
27-
- TOX_ENV=py2.7-djangomaster
6+
- TOX_ENV=py27-flake8
7+
- TOX_ENV=py27-docs
8+
- TOX_ENV=py34-django17
9+
- TOX_ENV=py33-django17
10+
- TOX_ENV=py32-django17
11+
- TOX_ENV=py27-django17
12+
- TOX_ENV=py34-django16
13+
- TOX_ENV=py33-django16
14+
- TOX_ENV=py32-django16
15+
- TOX_ENV=py27-django16
16+
- TOX_ENV=py26-django16
17+
- TOX_ENV=py34-django15
18+
- TOX_ENV=py33-django15
19+
- TOX_ENV=py32-django15
20+
- TOX_ENV=py27-django15
21+
- TOX_ENV=py26-django15
22+
- TOX_ENV=py27-django14
23+
- TOX_ENV=py26-django14
24+
- TOX_ENV=py34-djangomaster
25+
- TOX_ENV=py33-djangomaster
26+
- TOX_ENV=py32-djangomaster
27+
- TOX_ENV=py27-djangomaster
2828

2929
matrix:
3030
fast_finish: true
3131
allow_failures:
32-
- env: TOX_ENV=py3.4-djangomaster
33-
- env: TOX_ENV=py3.3-djangomaster
34-
- env: TOX_ENV=py2.7-djangomaster
32+
- env: TOX_ENV=py34-djangomaster
33+
- env: TOX_ENV=py33-djangomaster
34+
- env: TOX_ENV=py32-djangomaster
35+
- env: TOX_ENV=py27-djangomaster
3536

3637
install:
37-
- "pip install tox --download-cache $HOME/.pip-cache"
38+
- pip install tox
3839

3940
script:
4041
- tox -e $TOX_ENV

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: 21 additions & 3 deletions
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

@@ -100,7 +100,7 @@ For example, if your API relies on a third party service that may sometimes be u
100100

101101
**Signature:** `ParseError(detail=None)`
102102

103-
Raised if the request contains malformed data when accessing `request.DATA` or `request.FILES`.
103+
Raised if the request contains malformed data when accessing `request.data`.
104104

105105
By default this exception results in a response with the HTTP status code "400 Bad Request".
106106

@@ -140,7 +140,7 @@ By default this exception results in a response with the HTTP status code "405 M
140140

141141
**Signature:** `UnsupportedMediaType(media_type, detail=None)`
142142

143-
Raised if there are no parsers that can handle the content type of the request data when accessing `request.DATA` or `request.FILES`.
143+
Raised if there are no parsers that can handle the content type of the request data when accessing `request.data`.
144144

145145
By default this exception results in a response with the HTTP status code "415 Unsupported Media Type".
146146

@@ -152,5 +152,23 @@ Raised when an incoming request fails the throttling checks.
152152

153153
By default this exception results in a response with the HTTP status code "429 Too Many Requests".
154154

155+
## ValidationError
156+
157+
**Signature:** `ValidationError(detail)`
158+
159+
The `ValidationError` exception is slightly different from the other `APIException` classes:
160+
161+
* The `detail` argument is mandatory, not optional.
162+
* The `detail` argument may be a list or dictionary of error details, and may also be a nested data structure.
163+
* By convention you should import the serializers module and use a fully qualified `ValidationError` style, in order to differentiate it from Django's built-in validation error. For example. `raise serializers.ValidationError('This field must be an integer value.')`
164+
165+
The `ValidationError` class should be used for serializer and field validation, and by validator classes. It is also raised when calling `serializer.is_valid` with the `raise_exception` keyword argument:
166+
167+
serializer.is_valid(raise_exception=True)
168+
169+
The generic views use the `raise_exception=True` flag, which means that you can override the style of validation error responses globally in your API. To do so, use a custom exception handler, as described above.
170+
171+
By default this exception results in a response with the HTTP status code "400 Bad Request".
172+
155173
[cite]: http://www.doughellmann.com/articles/how-tos/python-exception-handling/index.html
156174
[authentication]: authentication.md

0 commit comments

Comments
 (0)