mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
Expand documentation on url key -> Location
Add documentation on changing this behaviour including a fairly basic example on altering it
This commit is contained in:
parent
689afd83cc
commit
de65da983e
|
@ -226,7 +226,19 @@ If the queryset is populated, this returns a `200 OK` response, with a serialize
|
||||||
|
|
||||||
Provides a `.create(request, *args, **kwargs)` method, that implements creating and saving a new model instance.
|
Provides a `.create(request, *args, **kwargs)` method, that implements creating and saving a new model instance.
|
||||||
|
|
||||||
If an object is created this returns a `201 Created` response, with a serialized representation of the object as the body of the response. If the representation contains a key named `url`, then the `Location` header of the response will be populated with that value.
|
If an object is created this returns a `201 Created` response, with a serialized representation of the object as the body of the response.
|
||||||
|
|
||||||
|
If the representation contains a key named `url`, then the `Location` header of the response will be populated with that value. This behaviour can be altered like so:
|
||||||
|
|
||||||
|
class DocumentView(CreateModelMixin):
|
||||||
|
# ....
|
||||||
|
|
||||||
|
def get_success_headers(self, data):
|
||||||
|
"""data is the object ready for JSON serialization
|
||||||
|
or similar.
|
||||||
|
Returned is a dict of headers, so for example {'X-Header':'OK'}
|
||||||
|
"""
|
||||||
|
return {}
|
||||||
|
|
||||||
If the request data provided for creating the object was invalid, a `400 Bad Request` response will be returned, with the error details as the body of the response.
|
If the request data provided for creating the object was invalid, a `400 Bad Request` response will be returned, with the error details as the body of the response.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user