mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 13:54:47 +03:00
Merge 42019550da
into b41808b79a
This commit is contained in:
commit
2f8ccd7c81
|
@ -206,7 +206,7 @@ If we try to create a snippet without authenticating, we'll get an error:
|
||||||
|
|
||||||
We can make a successful request by including the username and password of one of the users we created earlier.
|
We can make a successful request by including the username and password of one of the users we created earlier.
|
||||||
|
|
||||||
http -a tom:password POST http://127.0.0.1:8000/snippets/ code="print 789"
|
http -a tom:password POST http://127.0.0.1:8000/snippets/ code="print 789" owner=1
|
||||||
|
|
||||||
{
|
{
|
||||||
"id": 5,
|
"id": 5,
|
||||||
|
|
|
@ -104,9 +104,12 @@ If we're going to have a hyperlinked API, we need to make sure we name our URL p
|
||||||
* Our user serializer includes a field that refers to `'snippet-detail'`.
|
* Our user serializer includes a field that refers to `'snippet-detail'`.
|
||||||
* Our snippet and user serializers include `'url'` fields that by default will refer to `'{model_name}-detail'`, which in this case will be `'snippet-detail'` and `'user-detail'`.
|
* Our snippet and user serializers include `'url'` fields that by default will refer to `'{model_name}-detail'`, which in this case will be `'snippet-detail'` and `'user-detail'`.
|
||||||
|
|
||||||
After adding all those names into our URLconf, our final `snippets/urls.py` file should look something like this:
|
After adding all those names into our URLconf, our final `snippets/urls.py` file should look like this:
|
||||||
|
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import url, include
|
||||||
|
from rest_framework.urlpatterns import format_suffix_patterns
|
||||||
|
from snippets import views
|
||||||
|
|
||||||
|
|
||||||
# API endpoints
|
# API endpoints
|
||||||
urlpatterns = format_suffix_patterns([
|
urlpatterns = format_suffix_patterns([
|
||||||
|
|
Loading…
Reference in New Issue
Block a user