Skip to content

Commit 6ad0be4

Browse files
committed
Merge remote-tracking branch 'reference/master' into feature/improve_schema_shortcut
* reference/master: use django 1.11rc1 in tox Leave parameters with regex pattern as String restored original formatting Do not hint BigAutoField as integer (outside of range) Mention where the mixins live Try to improve browser support Cleanup and refactor docs api.js script Move bootstrap modal data attrs to anchor Remove unused base.js script Correctly set scheme in coreapi TokenAuthentication reverted to fix the issue without changing setting DEFAULT_PAGINATION_CLASS is changed to 'None' add content block and breadcrumbs_empty block to allow base.html to be reused Update 7-schemas-and-client-libraries.md Updated testimonial name on funding site ID must start from 1 again
2 parents b558c9e + 0fdaf4f commit 6ad0be4

File tree

10 files changed

+260
-260
lines changed

10 files changed

+260
-260
lines changed

docs/api-guide/viewsets.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ You may need to provide custom `ViewSet` classes that do not have the full set o
235235

236236
To create a base viewset class that provides `create`, `list` and `retrieve` operations, inherit from `GenericViewSet`, and mixin the required actions:
237237

238+
from rest_framework import mixins
239+
238240
class CreateListRetrieveViewSet(mixins.CreateModelMixin,
239241
mixins.ListModelMixin,
240242
mixins.RetrieveModelMixin,

docs/topics/funding.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Sign up for a paid plan today, and help ensure that REST framework becomes a sus
147147
> It's really awesome that this project continues to endure. The code base is top notch and the maintainers are committed to the highest level of quality.
148148
DRF is one of the core reasons why Django is top choice among web frameworks today. In my opinion, it sets the standard for rest frameworks for the development community at large.
149149
>
150-
> — agconti, Django REST framework user
150+
> — Andrew Conti, Django REST framework user
151151
152152
---
153153

docs/tutorial/4-authentication-and-permissions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ We can make a successful request by including the username and password of one o
209209
http -a tom:password123 POST http://127.0.0.1:8000/snippets/ code="print 789"
210210

211211
{
212-
"id": 5,
212+
"id": 1,
213213
"owner": "tom",
214214
"title": "foo",
215215
"code": "print 789",

docs/tutorial/7-schemas-and-client-libraries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ view in our URL configuration.
4141
schema_view = get_schema_view(title='Pastebin API')
4242

4343
urlpatterns = [
44-
url('^schema/$', schema_view),
44+
       url(r'^schema/$', schema_view),
4545
...
4646
]
4747

rest_framework/schemas.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ def get_path_fields(self, path, method, view):
526526
title = ''
527527
description = ''
528528
schema_cls = coreschema.String
529+
kwargs = {}
529530
if model is not None:
530531
# Attempt to infer a field description if possible.
531532
try:
@@ -541,14 +542,16 @@ def get_path_fields(self, path, method, view):
541542
elif model_field is not None and model_field.primary_key:
542543
description = get_pk_description(model, model_field)
543544

544-
if isinstance(model_field, models.AutoField):
545+
if hasattr(view, 'lookup_value_regex') and view.lookup_field == variable:
546+
kwargs['pattern'] = view.lookup_value_regex
547+
elif isinstance(model_field, models.AutoField):
545548
schema_cls = coreschema.Integer
546549

547550
field = coreapi.Field(
548551
name=variable,
549552
location='path',
550553
required=True,
551-
schema=schema_cls(title=title, description=description)
554+
schema=schema_cls(title=title, description=description, **kwargs)
552555
)
553556
fields.append(field)
554557

@@ -600,7 +603,8 @@ def get_pagination_fields(self, path, method, view):
600603
if not is_list_view(path, method, view):
601604
return []
602605

603-
if not getattr(view, 'pagination_class', None):
606+
pagination = getattr(view, 'pagination_class', None)
607+
if not pagination or not pagination.page_size:
604608
return []
605609

606610
paginator = view.pagination_class()

0 commit comments

Comments
 (0)