Commit Graph

3520 Commits

Author SHA1 Message Date
Tom Christie
39a98c80a6 Fix 'get_page_number' implementation 2021-03-11 09:21:22 +00:00
Tom Christie
c05cbe2da2
Update pagination.py
Include `last_page_strings` logic *inside* the `get_page_number method.
2021-03-10 12:50:59 +00:00
sarath ak
6f6d402d04
Allow 'get_page' method for overriding #7626 (#7652) 2021-03-10 12:32:10 +00:00
Pierre Chiquet
c603b98403
Fix OpenAPISchema rendering for timedelta (#7641)
* Add failing test when rendering to json a schema with timedelta

* Fix JSONOpenAPIRenderer for fields with default=timedelta()

* fix isort

* fix test for python 3.5

Co-authored-by: Pierre Chiquet <pierre.chiquet@ubikey.fr>
2021-03-10 12:03:15 +00:00
Dmitry Mugtasimov
a3ae8ea77e
Do not do SELECT count(*) FROM ... if pagination is not requested (#6098)
* Do not do `SELECT count(*) FROM ...` if pagination is not requested

* Update pagination.py

Co-authored-by: Tom Christie <tom@tomchristie.com>
2021-03-09 12:06:12 +00:00
Vitor Hugo
4e0d6c4118
Update default.css (#7643)
When I apply a theme to the bootstrap used in the project, boolean inputs are out of line with the rest of the form. With this small payment, this no longer occurs.
2021-03-09 11:54:58 +00:00
Berkant
95ae92ef23
Fix #7706 (#7724)
Handle non-dict values for NestedSerializer during BrowsableAPI
rendering.
2021-03-09 11:34:18 +00:00
David Kerkeslager
05512160ab
Respect allow_null=True on DecimalFields (#7718)
* Handle None in to_representation()
* Return None as '' in to_representation() when coerce_to_string=True
* Handle '' as None in to_internal_value(), for symmetry with
  to_representation(), and because the empty concept doesn't make sense
  for Decimal.
2021-03-09 10:49:03 +00:00
Cas Ebbers
393f867995
Overlooked translation in search.html (#7551) 2021-03-09 10:21:11 +00:00
kuter
e9a54e38e1
add support for Yes/No literals with BooleanField (#7701) 2021-03-09 10:17:30 +00:00
Jonathan Mortensen
de7468d0b4
support multi db atomic_requests (#7739) 2021-03-03 11:15:39 +00:00
Sebastian Jordan
19655edbf7
Handle tuples same as lists in ValidationError detail context (#7647) 2021-01-06 13:13:34 +00:00
Xavier Ordoquy
47cfbdac97 Translations updated from transifex and compiled 2020-10-13 22:05:24 +02:00
Tom Christie
3799633cde Version 3.12.2 2020-10-13 14:17:53 +01:00
Aarni Koskela
0bdd537cc4
Ignore derivations of BrowsableAPIRenderer in OpenAPI schema (#7497)
* Ignore derivations of BrowsableAPIRenderer in OpenAPI schema
* Improve test_renderer_mapping test

Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es>
2020-10-12 16:40:26 +02:00
Thomas Leese
eff97efa28
Don't catch exceptions in get_queryset (#7480)
In the `to_internal_value` method of the primary key and slug related fields, `TypeError`s and `ValueError`s are caught from `self.get_queryset().get(...)` and presented to the user. This works fine for most cases, but can cause problems if the exception is coming from `self.get_queryset()` rather than from the `.get(...)`.

It means errors in the `get_queryset` method can be hidden and presented back to the user as though, for example, the input provided to the `to_internal_value` was the wrong type, whereas in reality there's a bug in the `get_queryset` method and therefore it should bubble up and be exposed as a server error.

I've decided to fix this because twice now I've had to debug why I'm seeing `invalid_type` errors from my serializer (errors like `wrong pk type - int` when the `pk` type on my model is `int`) when the real problem was a bug in my custom `get_queryset` method.
2020-10-10 18:02:21 +01:00
David Smith
79c37d0dc3
Return NotImplemented sooner for ErrorDetail equality test (#7531)
The test suite raises warnings when tested against Python 3.9
`DeprecationWarning: NotImplemented should not be used in a boolean context`

Where `r` returns `NotImplemented` then this change returns `NotImplemented` first to avoid the comparison test.
2020-10-09 12:21:22 +01:00
Kryštof Pilnáček
79daf315c4
Fix: authtoken.TokenProxy cannot be proxy when not installed (#7571)
closes https://github.com/encode/django-rest-framework/issues/7442
2020-10-09 12:16:15 +01:00
Adam Johnson
7921e9af43
Fix RemovedInDjango40Warning for middleware get_resopnse() (#7513)
Fixes #7417.

Fixes all these issues seen with `tox -e py38-django31`:

```
  /Users/chainz/Documents/Projects/django-rest-framework/tests/test_request.py:208: RemovedInDjango40Warning: Passing None for the middleware get_response argument is deprecated.
    SessionMiddleware().process_request(self.wrapped_request)

tests/test_requests_client.py: 1 test with warning
tests/test_testing.py: 4 tests with warnings
tests/test_throttling.py: 1 test with warning
tests/authentication/test_authentication.py: 4 tests with warnings
tests/browsable_api/test_browsable_api.py: 4 tests with warnings
  /Users/chainz/Documents/Projects/django-rest-framework/rest_framework/authentication.py:139: RemovedInDjango40Warning: Passing None for the middleware get_response argument is deprecated.
    check = CSRFCheck()
```
2020-10-09 10:48:03 +01:00
Xavier Ordoquy
ebc1ebf0c4
Merge pull request #7481 from smithdc1/app-config
default_app_config application variable is deprecated in Django 3.2
2020-10-06 22:16:29 +02:00
Adam Johnson
91916a4db1
Fix NullBooleanField warning (#7565)
The argument to Field is 'allow_null'.
2020-09-30 13:47:06 +01:00
Tom Christie
05b3865838 Version 3.12.1 2020-09-28 16:18:23 +01:00
Hugo Rodger-Brown
995188f8c5
Add missing TokenProxy migration (#7557)
Fixes #7554
2020-09-28 16:16:18 +01:00
Tom Christie
6f7aad8ffa
Placeholder for 3.12 release (#7379)
* Placeholder for 3.12 release

* Updating release notes

* Updating release notes

* Updating release notes

* Update release notes

* Fix typo

* Basic structure for release announcement

* 3.12 release notes

* Version 3.12.0
2020-09-28 10:47:50 +01:00
Esieboma Jeremiah
9ee67bbff7
corrects typographical error in line 118 (#7553) 2020-09-28 08:52:17 +01:00
Tom Christie
ae649336b1
Drop urlize_quoted_links (#7548) 2020-09-23 15:39:06 +01:00
Francisco Couzo
6b632c15b1
Remove unnecessary type conversions (#7526) 2020-09-08 15:42:01 +01:00
Adam Johnson
410575dace
Replace all url() calls with path() or re_path() (#7512)
* url() is deprecated in Django 3.1

* update given feedbacks on url() is deprecated in Django 3.1

* Fix test_urlpatterns.py to continue testing mixed re_path() and path()

* Fix one missed reference

Co-authored-by: sanjusci <sanju.sci9@gmail.com>
2020-09-08 15:32:27 +01:00
David Smith
d5461e93fe
Bump flake8 to 3.8.3 (#7521) 2020-09-05 10:02:27 +02:00
David Smith
b8ab30683a default_app_config application variable is deprecated in Django 3.2 2020-09-03 21:57:41 +01:00
Charles
35c0abf24e
Change Token.generate_key to a Classmethod (#7502)
* adds classmethod decorator to generate_key and test to confirm change is acceptable

* self -> cls
2020-09-03 11:51:03 +01:00
Ryan P Kilby
f323049ecc
Fix pk-only optimization for properties (#7142)
* Add callable/prop tests for pk-only optimization

* Fix related field pk-only optimization for props
2020-09-03 11:49:15 +01:00
Bob Thomas
b3e02592d0
Add support for Django 3.1 JSONField (#7467)
Django 3.1 adds a new generic JSONField to replace the PostgreSQL-specific one. This adds support for the new field type, which should behave the same as the existing PostgreSQL field.

Django's new JSONField also includes support for a custom "decoder", so add support for that in the serializer field.
2020-09-03 11:47:11 +01:00
Vlad
e215db206a
Updated url()'s with path() and re_path() (#7492) 2020-08-25 13:50:02 +02:00
Justin Duke
48c327c681
Fix schema typo (#7491) 2020-08-24 03:44:34 -07:00
David Smith
355afcf64b
isort v5 (#7484) 2020-08-17 13:26:56 -07:00
Ryan P Kilby
1e383f103a
Check extra action func.__name__ (#7098) 2020-08-05 21:29:47 -07:00
Michael K
0d2bbd3177
Fix Request docstring kwarg names (#7443) 2020-08-05 16:51:06 -07:00
John Vandenberg
599e2b183d
urlpatterns: Remove unnecessary branching (#7405)
Functions path and register_converter are constants.
2020-07-23 19:26:35 +02:00
Anton Agestam
76232437d4
Allow type checkers to make serializers generic (#7385) 2020-07-07 10:05:36 +01:00
Minjae Kim
d46d5cbaaa
Not include charset when charset is None (#7400) 2020-07-07 09:58:32 +01:00
Xavier Ordoquy
28983cb28b
Merge pull request #7290 from encode/xordoquy/fix_action_namespace
Fix viewsets action urls with namespaces (#7287)
2020-07-03 20:18:18 +02:00
Dhaval Mehta
5ce237e004
Corrected regex serialization for OpenAPI. (#7389)
* replace \Z by \z in regex

* fix test cases for Django >= 3.0

* fix isort

* Added comment for why `\z`.

Co-authored-by: Carlton Gibson <carlton@noumenal.es>
2020-06-28 14:28:59 +02:00
Carlton Gibson
e2bd3b6a57
Adjusted token admin to map to user ID. (#7341)
Closes #6131.

* Adds a proxy model for Token that uses the user.pk, rather than it's own.
* Adjusts Admin to map back from User ID to token instance.
2020-06-15 11:43:09 +01:00
Jair Henrique
bb795674f8
Drop all compat support to Django < 2 urls (#7337) 2020-05-14 20:31:38 +02:00
Jair Henrique
65add6679d
Remove unnecessary test skips (#7336) 2020-05-14 14:49:04 +01:00
Jair Henrique
b83e9121f3
Remove compat urls for Django < 2.0 (#7335) 2020-05-14 14:48:14 +01:00
Jair Henrique
aed74961ba
Remove compat for ProhibitNullCharactersValidator (#7333) 2020-05-14 08:24:09 +01:00
johnthagen
fccfdd21c0
Remove object inheritance in docs (#7332) 2020-05-13 17:54:46 -07:00
Carlton Gibson
8bb9a37f4b
Removed duplicated class RemovedInDRF314Warning.
Added accidently in e888fc11c7

Co-authored-by: Jair Henrique <jair.henrique@gmail.com>
2020-05-13 20:41:53 +02:00