Skip to content

Commit

Permalink
Merge pull request #2 from tomchristie/master
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
BrickXu committed Dec 2, 2014
2 parents 7165496 + d1fe61c commit 81870b6
Show file tree
Hide file tree
Showing 79 changed files with 2,217 additions and 5,574 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*~
.*

html/
site/
htmlcov/
coverage/
build/
Expand Down
53 changes: 27 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,41 @@
language: python

python: 2.7

sudo: false

env:
- TOX_ENV=flake8
- TOX_ENV=py3.4-django1.7
- TOX_ENV=py3.3-django1.7
- TOX_ENV=py3.2-django1.7
- TOX_ENV=py2.7-django1.7
- TOX_ENV=py3.4-django1.6
- TOX_ENV=py3.3-django1.6
- TOX_ENV=py3.2-django1.6
- TOX_ENV=py2.7-django1.6
- TOX_ENV=py2.6-django1.6
- TOX_ENV=py3.4-django1.5
- TOX_ENV=py3.3-django1.5
- TOX_ENV=py3.2-django1.5
- TOX_ENV=py2.7-django1.5
- TOX_ENV=py2.6-django1.5
- TOX_ENV=py2.7-django1.4
- TOX_ENV=py2.6-django1.4
- TOX_ENV=py3.4-djangomaster
- TOX_ENV=py3.3-djangomaster
- TOX_ENV=py2.7-djangomaster
- TOX_ENV=py27-flake8
- TOX_ENV=py27-docs
- TOX_ENV=py34-django17
- TOX_ENV=py33-django17
- TOX_ENV=py32-django17
- TOX_ENV=py27-django17
- TOX_ENV=py34-django16
- TOX_ENV=py33-django16
- TOX_ENV=py32-django16
- TOX_ENV=py27-django16
- TOX_ENV=py26-django16
- TOX_ENV=py34-django15
- TOX_ENV=py33-django15
- TOX_ENV=py32-django15
- TOX_ENV=py27-django15
- TOX_ENV=py26-django15
- TOX_ENV=py27-django14
- TOX_ENV=py26-django14
- TOX_ENV=py34-djangomaster
- TOX_ENV=py33-djangomaster
- TOX_ENV=py32-djangomaster
- TOX_ENV=py27-djangomaster

matrix:
fast_finish: true
allow_failures:
- env: TOX_ENV=py3.4-djangomaster
- env: TOX_ENV=py3.3-djangomaster
- env: TOX_ENV=py2.7-djangomaster
- env: TOX_ENV=py34-djangomaster
- env: TOX_ENV=py33-djangomaster
- env: TOX_ENV=py32-djangomaster
- env: TOX_ENV=py27-djangomaster

install:
- "pip install tox --download-cache $HOME/.pip-cache"
- pip install tox

script:
- tox -e $TOX_ENV
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,15 @@ There are many great markdown editors that make working with the documentation r

## Building the documentation

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

./mkdocs.py
mkdocs build

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

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

./mkdocs.py -p
mkdocs serve

## Language style

Expand Down
1 change: 1 addition & 0 deletions docs/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
www.django-rest-framework.org
2 changes: 1 addition & 1 deletion docs/api-guide/authentication.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a class="github" href="authentication.py"></a>
source: authentication.py

# Authentication

Expand Down
6 changes: 3 additions & 3 deletions docs/api-guide/content-negotiation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a class="github" href="negotiation.py"></a>
source: negotiation.py

# Content negotiation

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

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.

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

---

Expand Down Expand Up @@ -62,7 +62,7 @@ request when selecting the appropriate parser or renderer.
Select the first parser in the `.parser_classes` list.
"""
return parsers[0]

def select_renderer(self, request, renderers, format_suffix):
"""
Select the first renderer in the `.renderer_classes` list.
Expand Down
24 changes: 21 additions & 3 deletions docs/api-guide/exceptions.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a class="github" href="exceptions.py"></a>
source: exceptions.py

# Exceptions

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

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

Raised if the request contains malformed data when accessing `request.DATA` or `request.FILES`.
Raised if the request contains malformed data when accessing `request.data`.

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

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

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

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

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

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

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

## ValidationError

**Signature:** `ValidationError(detail)`

The `ValidationError` exception is slightly different from the other `APIException` classes:

* The `detail` argument is mandatory, not optional.
* The `detail` argument may be a list or dictionary of error details, and may also be a nested data structure.
* 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.')`

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:

serializer.is_valid(raise_exception=True)

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.

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

[cite]: http://www.doughellmann.com/articles/how-tos/python-exception-handling/index.html
[authentication]: authentication.md
Loading

0 comments on commit 81870b6

Please sign in to comment.