Commit Graph

551 Commits

Author SHA1 Message Date
Tom Christie
dea601dc86 Merge pull request #4222 from NewVadim/master
Fix partial update for the ListSerializer.
2017-05-02 10:17:12 +01:00
Dave Allan
11d8e4df88 PoC Add JSONBoundField to serializers (Fixes #4999)
Per issue #4999, JSONFields are not rendered properly in the DRF
browsable API HTML forms.  This patch attempts to fix that behavior by
introducing a JSONBoundField helper similar to the NestedBoundField
helper.
2017-04-26 14:10:47 -04:00
Tom Christie
2df80c3c9d Merge pull request #4688 from theosotr/feature-source
Support usage of 'source' in `extra_kwargs`.
2017-03-13 10:25:38 +00:00
Ran Benita
7a408f6cd2 Guard against the possible misspelling readonly_fields in model serializers
Fixes #4897.
2017-02-22 13:27:23 +02:00
Isaac Stone
289e1e440e Check for collection.Mapping instead of dict
issue #4901
2017-02-19 13:10:03 -08:00
Artem Muterko
773b68e188 Fix typos in Python files 2017-01-08 15:36:49 +02:00
Ryan P Kilby
11fd3bf108 Add disabling of declared fields on serializer subclasses (#4764)
* Add test for disabling declared fields on child
* Check that declared base field is not in attrs
* Update meta inheritance docs to include serializer
* Test that meta fields cannot be declared as None
* Add docs example for declarative field disabling
2017-01-03 21:14:19 +00:00
Thodoris Sotiropoulos
4c2d6b9bb7 Do not ignore source when building fields dynamically
This commit fixes the issue when you set the keyword argument `source`
and your have not set the serializer fields explicitly. Then the
construction of field failed because there is not actually any model
field with that name.

However, you are still able to imply the name of model field by
providing the `source` keyword argument.
2016-11-17 18:51:22 +02:00
Tom Christie
8bab7f8d58 Only apply the nested writes test to writable fields. (#4669) 2016-11-10 16:36:56 +00:00
Ryan P Kilby
d92b24a0b7 Make serializer fields import explicit (#4628) 2016-11-01 10:27:11 +00:00
Tom Christie
f1bdce17b5 Fix for case of ListSerializer with single item (#4609) 2016-10-21 15:21:23 +01:00
Tom Christie
8d0a91b002 Fix 3674 (#4571)
Handle ModelSerializer case for relationships to models with custom pk.
2016-10-13 12:43:43 +01:00
Tom Christie
88c6c380c5 Use field.source to perform check for writable nested field, not key (#4568) 2016-10-12 16:51:01 +01:00
Tom Christie
b419970431 Handle empty data with serializer (#4564) 2016-10-12 10:47:17 +01:00
Tom Christie
a3802504a0 Error codes (#4550)
Add error codes to `APIException`
2016-10-11 10:25:21 +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
orf
d540f0262b Improve Create to show the original exception traceback (#3508) 2016-08-19 14:42:13 +01:00
Dmitry Dygalo
e1768bdc16 Fixed various typos (#4366) 2016-08-08 09:32:22 +01:00
Tom Christie
a9a097496e extra_kwargs takes precedence over uniqueness kwargs (#4349) 2016-08-02 14:33:15 +01:00
Tom Christie
6a7d34ec34 Unique together checks should apply to fields that are read only, but have a default. (#4316) 2016-07-27 15:40:04 +01:00
Tom Christie
8385ae42c0 3.4.0 Release (#4258)
* 3.4.0 Release

* Version 3.4 release

* Full release notes

* Update translation files

* Update release documentation

* Update release notes

* Docs on supporting alternate schema formats

* Add schema_renderers to DefaultRouter
2016-07-13 16:30:41 +01:00
Vadim
c0f4dfd8f3 Add tests for the ListSerializer for the TestSerializerPartialUsage.
Additional fix partial update for the ListSerializer.
2016-06-29 09:48:31 +03:00
Vadim
53a1205dd0 Fix partial update for the ListSerializer. 2016-06-24 15:04:18 +03:00
Tom Christie
c3b7fba918 Exclude read_only=True fields from unique_together validation & add docs. (#4192)
* Exclude read_only=True fields from unique_together validation
* Test to ensure that unique_together validators can be removed
* Do not add uniquness_extra_kwargs when validators are explicitly declared.
* Add docs on validation in complex cases
2016-06-13 13:31:12 +01:00
Tom Christie
a5f822d067 Empty cases of .validated_data and .errors as lists not dicts for ListSerializer (#4180) 2016-06-08 15:55:09 +01:00
Tom Christie
9c996d7d2a Clean up existing deprecation warnings. (#4166)
* Add Meta.fields = '__all__' to serializer classes where required.
* Add explicit on_delete=models.CASCADE to ForeignKey fields.
* Use '.remote_field' and '.model' in preference to '.rel' and '.to' when inspecting model fields.
* Use new value_from_object in preference to internal _get_val_from_obj
2016-06-02 14:39:10 +01:00
Xavier Ordoquy
0e8306341d Merge pull request #3936 from carltongibson/null-uuid-fk-take2
Fix None UUID ForeignKey serialization
2016-03-22 22:46:33 +01:00
Carlton Gibson
2ef74cfa61 Bring check for null fk to BaseSerializer.to_representation 2016-03-13 20:39:19 +01: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
Federico Bond
03b5438d07 Add missing space in serializer error message 2016-02-11 15:09:21 -03:00
Tom Christie
f01a3d9c36 Merge pull request #3801 from koordinates/fix-nested-validation-error
Fix nested validation error being rendered incorrectly.
2016-01-07 09:22:23 +00:00
Kevin Massey
7cd3933144 Fixes #3804, avoiding update of Meta.extra_kwargs
Added unit test to cover.
2016-01-06 15:04:51 -05:00
Craig de Stigter
651319e2da Fix nested validation error being rendered incorrectly.
Previously an extra list wrapped nested validation errors raised from serializer's validate() methods.
That was inconsistent with the format of validation errors raised by validate_<fieldname> methods.
i.e. these two resulted in *different* behaviour:

    def validate_foo(self):
        raise ValidationError(['bar'])

    def validate(self):
        raise ValidationError({'foo': ['bar']})
2016-01-06 16:05:43 +13:00
Tom Christie
54b79db214 Proper 'is primary key' checking 2015-11-04 14:37:32 +00:00
likeon
322bda8159 Added support for the to_field on ForeignKey fields 2015-10-21 15:33:18 +03:00
Omer Katz
2e178bc970 Replaced all dict and set conversions from lists to dict and set literals. 2015-10-17 12:00:11 +03:00
Tom Christie
10dbf1316f Added JSONField. Closes #3170. 2015-09-28 17:25:52 +01:00
Tom Christie
ca8313aeac Merge branch 'master' into version-3.3
Conflicts:
	docs/topics/release-notes.md
2015-09-28 10:57:14 +01:00
Tom Christie
6284bceaaf Merge pull request #3363 from tomchristie/dont-access-settings-on-import
Access settings lazily, not at module import.
2015-09-24 15:42:31 +01:00
paolopaolopaolo
7640bfea9e Add assert statement to .save() method in Serializer:
- Asserts that `_data` does not exist when calling `.save()`
2015-09-22 11:49:51 -07:00
Tom Christie
a3067bea55 Merge branch 'master' into version-3.3 2015-09-17 16:24:46 +01:00
Xavier Ordoquy
4404d40f60 Only pass allow_empty to the ListSerializer if it was in the arguments.
Helps with backward compatibility.
2015-09-06 23:02:44 +02:00
Xavier Ordoquy
dcdd765647 Avoid passing allow_empty to the ListSerializer children. 2015-09-03 17:27:33 +02:00
Tom Christie
10da18b20b Access settings lazily, not at module import 2015-09-03 16:24:13 +01:00
José Padilla
654e0e4527 Update ModelSerializer fields behavior 2015-08-27 13:09:08 -04: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
a543fae180 Merge pull request #2766 from delinhabit/allow-null-list-serializer
Modify subtle ChildSerializer(many=True, allow_null=True) behavior.
2015-07-31 10:11:21 +01:00
Tom Christie
1b3b01e042 Remove unused imports 2015-07-30 15:59:27 +01:00
Tom Christie
c203ca4c64 Deprecations 2015-07-30 15:26:42 +01:00
Tom Christie
402fb39396 HStoreField maps to ListField(CharField(allow_blank=True). Closes #2659. 2015-07-27 13:18:49 +01:00