Carlton Gibson
da535d31dd
Fixed active timezone handling for non ISO8601 datetimes. ( #5833 )
...
* Add failing test for to_representation with explicit default timezone
See discussion here:
https://github.com/encode/django-rest-framework/pull/5435#issuecomment-364054509
* Always run enforce_timezone
2018-02-16 16:47:49 +01:00
Ryan P Kilby
2709de1310
Add HStoreField, postgres fields tests ( #5654 )
...
* Test postgres field mapping
* Add HStoreField
* Ensure 'HStoreField' child is a 'CharField'
* Add HStoreField docs
2018-01-15 15:52:30 +01:00
Jon Dufresne
ffe3dbb1b1
Perfer iter(dict) over iter(dict.keys()) ( #5736 )
...
Calling dict.keys() is unnecessary. The two are functionally equivalent
on modern Pythons.
Inspired by Lennart Regebro's talk "Prehistoric Patterns in Python" from
PyCon 2017.
https://www.youtube.com/watch?v=V5-JH23Vk0I
2018-01-08 09:49:46 +00:00
Ryan P Kilby
6bd773e7f8
Improve composite field child errors ( #5655 )
...
* Fixup DictField test descriptions
* Nest ListField/DictField errors under the idx/key
* Add nested ListField/DictField tests
2018-01-02 10:45:59 +01:00
Jon Dufresne
ff556a91fd
Remove references to unsupported Django versions in docs and code ( #5602 )
...
Per the trove classifiers, DRF only supports Django versions 1.10+. Can
drop documentation, code comments, and workarounds for older Django
versions.
2017-11-20 09:35:54 +01:00
Sergei Azarkin
d49d796c85
Change ImageField validation pattern, use validators from DjangoImageField ( #5539 )
2017-11-06 11:14:37 +01:00
Jon Dufresne
0552810410
Use dict and set literals instead of calls to dict() and set() ( #5559 )
...
Set literals are available on all supported Python versions. They are
idiomatic and always faster:
$ python3 -m timeit '{}'
10000000 loops, best of 3: 0.0357 usec per loop
$ python3 -m timeit 'dict()'
10000000 loops, best of 3: 0.104 usec per loop
$ python3 -m timeit '{1, 2, 3}'
10000000 loops, best of 3: 0.0754 usec per loop
$ python3 -m timeit 'set([1, 2, 3])'
1000000 loops, best of 3: 0.228 usec per loop
2017-11-06 10:03:01 +01:00
Carlton Gibson
331c31370f
Add rounding parameter to DecimalField ( #5562 )
...
* Adding rounding parameter to DecimalField.
* Using standard `assert` instead of `self.fail()`.
* add testcase and PEP8 multilines fix
* flake8 fixes
* Use decimal module constants in tests.
* Add docs note for `rounding` parameter.
2017-11-06 09:55:09 +01:00
Stephen Chisholm
93e75ec138
Catch OverflowError for "out of range" datetimes ( #5546 )
...
* Add test for #5545
* Catch OverflowError for "out of range" datetimes
2017-10-31 10:17:08 +01:00
Ryan P Kilby
b64f8066c0
Add json util wrapper, failing JSONField test
2017-09-25 09:08:20 +02:00
Carlton Gibson
7d6d043531
Fix DateTimeField TZ handling ( #5435 )
...
* Add failing TZ tests for DateTimeField
- tests "current" timezone activation
- tests output for non-UTC timezones
* Update DateTimeField TZ aware/naive test output
* Fix DateTimeField TZ handling
* Add Release Note for BC change
2017-09-20 12:15:15 +02:00
Jeremy Nauta
c0a48622e1
Allow ChoiceField.choices
to be set dynamically ( #5426 )
...
## Description
The `choices` field for the `ChoiceField` class should be able to be edited after `ChoiceField.__init__` is called.
```
field = ChoiceField(choices=[1,2])
field.choices = [1] # Should no longer allow `2` as a choice
```
Currently, you must update `choices`, `grouped_choices`, and `choice_strings_to_values` to achieve this. This P/R keeps `grouped_choices` and `choice_strings_to_values` in sync whenever the `choices` are edited.
2017-09-20 11:33:50 +02:00
Ryan P Kilby
ae95ed1ec2
Add repr(value) to the assert msg in FieldValues
2017-09-11 05:18:39 -04:00
Igor Tokarev
79be20a7c6
Updated supported values for the NullBooleanField ( #5387 )
...
* Updated supported values for the NullBooleanField.
* Added check for unhashable types in NullBooleanField.
2017-09-04 10:11:53 +01:00
Ryan P Kilby
26ebb88306
Revert 3288 ( #5313 )
...
* Add regression test for #2505 . Thanks @pySilver!
* Add regression test for #5087
* Revert "Cached the field's root and context property."
This reverts commit 792005806b
.
2017-08-07 16:52:09 +01:00
Tom Christie
6d4d4dfd04
Ensure closables in request.FILES get closed. ( #5262 )
...
Ensure closables on `.FILES` get closed.
2017-07-10 13:42:02 +01:00
Tom Christie
39f6f1137c
Merge pull request #5261 from encode/validation-error-on-invalid-timezone-parsing
...
Raise validation error on invalid timezone parsing.
2017-07-10 11:27:28 +01:00
Tom Christie
41901185d2
Ignore timezone test case for Django 1.8, due to differing behavior.
2017-07-10 11:18:26 +01:00
Tom Christie
7d240a2e50
Minor cleanup in test.
2017-07-10 10:30:39 +01:00
Tom Christie
c7e2bad524
Merge pull request #5189 from myrubapa/master
...
Fix API documentation templates do not check for user authentication #5162
2017-07-10 10:28:33 +01:00
Tom Christie
bf7fcc495b
Raise validation error on invalid timezone parsing.
2017-07-10 10:14:31 +01:00
dmmatson
302a9d089e
Fixed tests on Windows. Added unicode support to SlugField
2017-06-23 23:11:17 -06:00
Bekhzod Tillakhanov
84e22cc2f3
Scheme fix when unauth and Flask8 lint fix
2017-05-30 00:15:07 +05:00
Sergey Petrunin
b0a0c30bfe
Added pytz exception in compat module.
...
Mock pytz.timezone localize in tests.
Ref: #4986
2017-03-22 00:03:32 -04:00
Sergey Petrunin
e4a1bd140b
Update error message.
...
Ref: #4986
2017-03-20 18:47:25 -04:00
Sergey Petrunin
d4726dab81
Fix bug for not existent or ambiguous datetime during native to aware conversion in timezone with DST.
...
Ref: #4986
2017-03-18 23:13:26 -04:00
Sergey Petrunin
1ee54fb85c
Added test for DateTimeField validation when server has timezone with DST and input is a native time in a DST shift interval.
...
Added pytz to requirements-testing.txt to reproduce the case.
2017-03-15 23:45:41 -04:00
李扬
cbad236f6d
Add max_length and min_length arguments for ListField ( #4877 )
2017-02-06 09:36:03 +00:00
Mariusz Felisiak
5c0f9f147c
Removed unnecessary utc wrapper. ( #4839 )
2017-01-23 16:22:32 +00:00
Asif Saifuddin Auvi
026a8d8707
make lint happy with isort --recursive
2017-01-18 22:15:44 +06:00
Asif Saifuddin Auvi
006ae46092
remove trailing comma
2017-01-18 21:40:07 +06:00
Asif Saifuddin Auvi
326e09dde9
added utc compat to tests of fields
2017-01-18 20:01:18 +06:00
Asif Saifuddin Auvi
4f6c326a99
converted remaining unittes asserts of fields test to pytest ( #4724 )
2016-11-30 12:52:32 +00:00
Ryan P Kilby
eafc9a2393
Fix is_simple_callable with variable args, kwargs ( #4622 )
2016-10-25 20:47:24 +01:00
Tom Christie
26e51ecd6c
When HTML form input is used with JSONField, treat the input as a JSON encoded string, not a JSON primative. ( #4565 )
2016-10-12 14:04:10 +01:00
Tom Christie
0dec36eb41
Version 3.5 ( #4525 )
...
* Start test case
* Added 'requests' test client
* Address typos
* Graceful fallback if requests is not installed.
* Add cookie support
* Tests for auth and CSRF
* Py3 compat
* py3 compat
* py3 compat
* Add get_requests_client
* Added SchemaGenerator.should_include_link
* add settings for html cutoff on related fields
* Router doesn't work if prefix is blank, though project urls.py handles prefix
* Fix Django 1.10 to-many deprecation
* Add django.core.urlresolvers compatibility
* Update django-filter & django-guardian
* Check for empty router prefix; adjust URL accordingly
It's easiest to fix this issue after we have made the regex. To try
to fix it before would require doing something different for List vs
Detail, which means we'd have to know which type of url we're
constructing before acting accordingly.
* Fix misc django deprecations
* Use TOC extension instead of header
* Fix deprecations for py3k
* Add py3k compatibility to is_simple_callable
* Add is_simple_callable tests
* Drop python 3.2 support (EOL, Dropped by Django)
* schema_renderers= should *set* the renderers, not append to them.
* API client (#4424 )
* Fix release notes
* Add note about 'User account is disabled.' vs 'Unable to log in'
* Clean up schema generation (#4527 )
* Handle multiple methods on custom action (#4529 )
* RequestsClient, CoreAPIClient
* exclude_from_schema
* Added 'get_schema_view()' shortcut
* Added schema descriptions
* Better descriptions for schemas
* Add type annotation to schema generation
* Coerce schema 'pk' in path to actual field name
* Deprecations move into assertion errors
* Use get_schema_view in tests
* Updte CoreJSON media type
* Handle schema structure correctly when path prefixs exist. Closes #4401
* Add PendingDeprecation to Router schema generation.
* Added SCHEMA_COERCE_PATH_PK and SCHEMA_COERCE_METHOD_NAMES
* Renamed and documented 'get_schema_fields' interface.
2016-10-10 13:03:46 +01:00
Tom Christie
4655501d51
Fix regression of RegexField
. ( #4490 )
...
* Don't deepcopy 'regex' arguments, instead treat as immutable.
2016-09-15 12:44:45 +01:00
Tom Christie
f16e880167
Stricter type validation for CharField. ( #4380 )
...
Stricter type validation for CharField
2016-08-10 17:22:19 +01:00
Tom Christie
48f3db36d6
Allow optional max_digits on DecimalField ( #4377 )
2016-08-10 14:39:26 +01:00
Dmitry Dygalo
e1768bdc16
Fixed various typos ( #4366 )
2016-08-08 09:32:22 +01:00
Tom Christie
5500b265bc
Test cases for DictField with allow_null options ( #4348 )
2016-08-02 14:14:36 +01:00
Tom Christie
46a44e52aa
Quantize incoming digitals ( #4339 )
2016-08-01 17:15:41 +01:00
Tom Christie
aa349fe767
Handle non-string input for IP fields ( #4338 )
2016-08-01 16:14:26 +01:00
kiyoqoko
6338ce80ab
Add localize keyword argument to DecimalField
( #4233 )
...
Add `localize` keyword argument for DecimalField
2016-07-06 16:07:16 +01:00
Tom Christie
9406e45b2c
Pass through strings as-in with DateTimeField ( #4196 )
2016-06-14 12:23:39 +01:00
Tom Christie
ebb4070467
Resolve TimeField representation for midnight value. ( #4107 )
2016-05-10 11:56:36 +01:00
Daniele Varrazzo
88c80fe2e9
Fixed DecimalField arbitrary precision support ( #4075 )
2016-04-27 17:04:01 +01:00
José Padilla
69c0de4faa
Merge pull request #3953 from akarambir/remove-old-django-checks
...
Closes #3952 : Remove old django checks from tests and compat
2016-02-19 11:08:45 -04:00
Karambir Singh Nain
69f1e3a9fd
Remove old django checks from tests and compat
...
Remove skipping of tests for Django<1.8. Remove several functions from compat.py not needed for Django>=1.8
2016-02-19 01:47:45 +05:30
Erick Wilder
8109752061
Closes #3937 . Support callable as the value of initial
for any serializer.Field
2016-02-17 10:52:21 +01:00
areski
4e01796303
Test for TimeField not handling empty values
2016-01-11 12:16:26 +01:00
Mikalai Radchuk
6b207d93d6
DateField.to_representation unicode compatibility
2016-01-11 13:11:01 +03:00
mjparker777
fc08236ab8
updated timefield also
2015-12-13 16:09:56 -07:00
mjparker777
81775dfbae
added missing comma
2015-12-13 12:27:08 -07:00
mjparker777
bf60c08010
Issue 3726 DateTimeField not handling empty values
2015-12-13 12:21:13 -07:00
bphillips
c153bcb479
Added validation to UUIDField to properly catch invalid input types (lists, tuples, etc).
2015-12-01 14:09:10 -05:00
Dawn Pattison
3ddbf92bf9
Remove unicode from exception value.
2015-11-13 10:41:57 -05:00
Dawn Pattison
5fdc4f22cf
Add tests to ensure ListField does not except dictionary as input.
2015-11-13 10:17:09 -05:00
Tom Christie
dad207de66
Don't attempt to test dicts (unordered)
2015-09-28 17:41:09 +01:00
Tom Christie
ec8098b7e2
Work around 2.x/3.x json.dumps() return type fuzziness
2015-09-28 17:32:36 +01:00
Tom Christie
10dbf1316f
Added JSONField. Closes #3170 .
2015-09-28 17:25:52 +01:00
Steven Loria
284f9faa07
Correctly handle [] and {} as invalid inputs to BooleanField
2015-09-11 23:12:18 -04:00
raphaelmerx
b9782b6850
DurationField accepts integers
2015-09-02 16:47:50 -07:00
Tom Christie
9ac646385f
Resolve empty HTML charfield behavior. Closes #3318 .
2015-08-24 10:13:16 +01:00
José Padilla
8af366a732
Raise error when source=
use on a child.
...
Closes #3292
2015-08-19 12:32:16 -04:00
Tom Christie
18af181191
Fix boolean checkboxes setting to False. Closes #3258 . Closes #2776 .
2015-08-13 09:56:03 +01:00
Keryn Knight
08d60f5cc2
Refs #3235 - Test demonstrating a single value passed to ListField is lost.
2015-08-07 11:41:56 +01:00
Tom Christie
33d6d4a420
Test more types of behavior in test_iter_options
2015-08-06 12:30:26 +01:00
Tom Christie
24dec32e7a
Added test_iter_options
2015-08-06 12:18:09 +01:00
Tom Christie
95a1550388
Merge branch 'grouped-choices-fix' of https://github.com/maxpeterson/django-rest-framework into maxpeterson-grouped-choices-fix
2015-08-06 10:04:52 +01:00
Tom Christie
38a1b3ec6b
Rationalize decimal logic. Closes #3222 .
2015-08-06 09:51:00 +01:00
Tom Christie
8d7c0a8474
Merge branch 'feature/filepathfield' of https://github.com/Ins1ne/django-rest-framework into Ins1ne-feature/filepathfield
2015-08-03 10:09:46 +01:00
Tom Christie
c5a04a8516
Add test for nullable ChoiceField and blank HTML input. Closes #2623 .
2015-07-27 13:51:03 +01:00
Aider Ibragimov
d845157983
Merge branch 'master' of https://github.com/tomchristie/django-rest-framework into feature/filepathfield
2015-07-18 23:34:07 +03:00
Tom Christie
0ccb148183
Support QueryDict list arguments with ListField. Closes #3155 .
2015-07-16 15:59:15 +01:00
Tom Christie
264d423493
Added allow_empty flag for ListField, ListSerializer, ManyRelation, MultipleChoiceField.
2015-07-16 13:51:15 +01:00
Tom Christie
d231f36588
Support default values being used for empty HTML fields. Closes #3130 .
2015-07-16 11:47:40 +01:00
Max Peterson
56b3f19605
Add support for grouped choices.
...
This also adds support for mixing single and paired choices:
```
[
('poor', 'Poor quality'),
'medium',
('good', 'Good quality'),
]
```
2015-07-03 12:27:01 +01:00
José Padilla
7351a3f6ca
Sort imports with isort
2015-06-25 16:55:51 -04:00
Tom Christie
39ece9bee0
Support allow_blank=False with trim_whitespace=True.
2015-06-24 13:32:54 +01:00
Xavier Ordoquy
dee5fb5647
Merge remote-tracking branch 'reference/master' into feature/ipaddress-fix
...
Conflicts:
docs/api-guide/fields.md
2015-06-04 14:21:33 +01:00
Xavier Ordoquy
0c66c7cfa6
Merge pull request #3000 from linovia/ovangle/uuid_format2
...
Add 'format' argument to UUIDField
2015-06-03 12:32:23 +01:00
Xavier Ordoquy
f8eacc5bc0
Merge pull request #2993 from linovia/bug/2894
...
MultipleChoiceField empties incorrectly on a partial update using multipart/form-data (#2894 )
2015-06-01 17:48:20 +01:00
Xavier Ordoquy
14055dd3f4
Merge pull request #2989 from ticosax/duration-field
...
Add DurationField
2015-06-01 17:38:57 +01:00
Nicolas Delaby
f701ecceb7
Add DurationField
2015-06-01 18:20:53 +02:00
Xavier Ordoquy
94e2d3ca61
Test case upgrade to use partial data
2015-06-01 16:13:12 +01:00
Xavier Ordoquy
989c08109b
Failing test case for #2894
2015-06-01 16:04:05 +01:00
Xavier Ordoquy
2f524ec1a3
Remove an extra MockHTMLDict definition.
2015-06-01 15:46:27 +01:00
Michał Hernas
069ea31cfb
Added test ensuring DecimalField accepts 2E+2
as 200 and validates
...
decimal place correctly.
2015-05-18 16:42:24 +02:00
David Sanders
8e84a9f6d0
Allow invalid outputs to pass through to_representation() for ChoiceField & MultipleChoiceField
2015-05-15 18:59:10 +10:00
Ryan Allen
cbea03c85b
DateField to_representation can handle str and empty values. Fixes #2656 , #2687 .
2015-04-23 19:31:46 -05:00
Ryan Allen
1f10a39d31
Match IntegerField validation with Django's, preventing decimal values being stored as ints, fixes #2835 .
...
Match IntegerField validation with Django IntegerField, prevents decimal values being stored as ints, fixes #2835
On branch master
2015-04-20 11:03:05 -04:00
Thomas Stephenson
236b731072
Add 'format' argument to UUIDField
...
To allow serializations to control the representation format of a
UUID value
2015-04-12 22:07:25 +10:00
Andrea Grandi
a0049dd489
Add a blank line to make lint happier
2015-03-22 23:21:09 +00:00
Andrea Grandi
1d883e0825
Add two more tests for IPAddressField, checking the IPv4 and IPv6 protocols separately
2015-03-22 16:46:16 +00:00
Aider Ibragimov
5f8338e276
Merge branch 'master' of https://github.com/tomchristie/django-rest-framework into feature/filepathfield
2015-03-03 14:34:18 +03:00
Aider Ibragimov
c20a0250df
add FilePathField, update docs
2015-03-03 14:34:06 +03:00
Kevin Wood
b582d52afb
Fix docstring formatting
2015-02-28 13:06:47 -08:00
Aider Ibragimov
de72022f80
Merge branch 'master' of https://github.com/Ins1ne/django-rest-framework into feature/ipaddress
2015-02-28 14:29:27 +03:00
Aider Ibragimov
4d5eee04a0
add IPAddressField, update docs
2015-02-28 10:11:38 +03:00