Commit Graph

405 Commits

Author SHA1 Message Date
Tom Christie
d1b2c8ac7f Absolute URLs for file fields 2014-09-29 14:12:26 +01:00
Tom Christie
9805a085fb UniqueTogetherValidator 2014-09-29 11:23:02 +01:00
Tom Christie
6090144608 Simplify serialization slightly 2014-09-26 14:32:44 +01:00
Tom Christie
2e87de0143 Added ListField 2014-09-26 13:08:20 +01:00
Tom Christie
8b8623c5f8 Allow many, partial and context in BaseSerializer 2014-09-26 12:48:20 +01:00
Tom Christie
43e80c74b2 Release notes 2014-09-26 11:56:29 +01:00
Tom Christie
2859eaf524 request.data attribute 2014-09-26 10:46:52 +01:00
Tom Christie
417fe1b675 Partial support 2014-09-25 13:37:26 +01:00
Tom Christie
64632da371 Clean up bind - no longer needs to be called multiple times in nested fields 2014-09-25 11:40:32 +01:00
Tom Christie
b22c9602fa Automatic field binding 2014-09-25 11:04:18 +01:00
Tom Christie
f4b1dcb167 OPTIONS support 2014-09-24 14:09:49 +01:00
Tom Christie
0404f09a7e NullBooleanField 2014-09-23 14:30:17 +01:00
Tom Christie
f22d0afc3d Tests for field choices 2014-09-23 14:15:00 +01:00
Tom Christie
cf72b9a8b7 Moar tests 2014-09-19 16:43:13 +01:00
Tom Christie
f90049316a Added a model update integration test 2014-09-18 15:47:27 +01:00
Tom Christie
106362b437 ModelSerializer.create() to handle many to many by default 2014-09-18 14:58:08 +01:00
Tom Christie
87734be5f4 Configuration correctness tests on ModelSerializer 2014-09-18 12:17:21 +01:00
Tom Christie
5b7e4af0d6 get_base_field() refactor 2014-09-18 11:20:56 +01:00
Tom Christie
c0155fd9dc Update comments 2014-09-17 14:11:53 +01:00
Tom Christie
d196608d5a Fix nested model serializer base class 2014-09-15 13:55:09 +01:00
Tom Christie
40dc588a37 Drop label from serializer fields when not needed 2014-09-15 09:50:51 +01:00
Tom Christie
afb28a44ad Dealing with reverse relationships 2014-09-12 21:32:20 +01:00
Tom Christie
6db3356c4d NON_FIELD_ERRORS_KEY setting 2014-09-12 10:21:35 +01:00
Tom Christie
0d354e8f92 to_internal_value() and to_representation() 2014-09-12 09:49:35 +01:00
Tom Christie
adcb64ab41 MethodField -> SerializerMethodField 2014-09-12 09:12:56 +01:00
Tom Christie
ab40780dc2 Tidy up lookup_class 2014-09-11 20:22:32 +01:00
Tom Christie
de301f3b66 Merge master 2014-09-11 13:20:44 +01:00
Tom Christie
80ba047347 Compat fixes 2014-09-10 16:57:22 +01:00
Tom Christie
01c8c0cad9 Added help_text argument to fields 2014-09-10 13:52:16 +01:00
Tom Christie
234369aefd Tweaks 2014-09-10 08:53:33 +01:00
Tom Christie
b1c07670ca Fleshing out serializer fields 2014-09-09 17:46:28 +01:00
Tom Christie
21980b800d More test sorting 2014-09-08 14:24:05 +01:00
Tom Christie
d934824bff Workin on 2014-09-05 16:29:46 +01:00
Tom Christie
f2852811f9 Getting tests passing 2014-09-02 17:41:23 +01:00
Tom Christie
ec096a1cac Add relations and get tests running 2014-09-02 15:07:56 +01:00
Timo Tuominen
e437520217 Generator implementation of class mapping. 2014-09-01 17:02:48 +03:00
Timo Tuominen
582f6fdd4b Add utility function to match classes in dictionary. 2014-09-01 15:54:33 +03:00
Timo Tuominen
ae84b8b0e8 Traverse the method resolution order when mapping serializer fields. 2014-09-01 15:03:39 +03:00
Timo Tuominen
82d4b20832 Add subclass matching to serializer field mapping. 2014-09-01 15:02:49 +03:00
Tom Christie
4ac4676a40 First pass 2014-08-29 16:46:26 +01:00
Tom Christie
63d02dbea8 Drop six from compat. 1.4.2 is now the lowest supported version. 2014-08-19 17:06:55 +01:00
Tom Christie
bf09c32de8 Code linting and added runtests.py 2014-08-19 13:28:07 +01:00
Tom Christie
e385a7b8eb Merge master 2014-08-19 10:11:10 +01:00
John Whitlock
34c1da3515 ModelSerializer.restore_object - errors as list
When a ValueError is raised in ModelSerializer.restore_object, the error
is set to a one-element list, rather than a bare string.
2014-08-13 15:31:25 -05:00
Xavier Ordoquy
2489e38a06 Merge remote-tracking branch 'origin/master' into 2.4.0
Conflicts:
	.travis.yml
	docs/api-guide/viewsets.md
	rest_framework/serializers.py
	rest_framework/throttling.py
	tests/test_generics.py
	tests/test_serializers.py
	tox.ini
2014-06-23 14:02:45 +02:00
Piper Merriam
807f7a6bb9 Fix _resolve_model to work with unicode strings 2014-05-22 15:18:51 -06:00
allenhu
a1a3ad7639 fix pep8 2014-05-19 09:53:05 +08:00
Xavier Ordoquy
5c12b07681 Added missing import. 2014-05-16 19:40:02 +02:00
Xavier Ordoquy
56b4390316 Merge remote-tracking branch 'origin/master' into 2.4.0
Conflicts:
	.travis.yml
	rest_framework/serializers.py
	rest_framework/tests/test_authentication.py
2014-04-30 22:21:26 +02:00
Emanuele Pucciarelli
f54399ea77 Merge remote-tracking branch 'upstream/master'
Conflicts:
	rest_framework/tests/models.py
2014-04-29 21:41:53 +02:00
Sergey Sinitsyn
a6e525cf3a Add help_text and verbose_name attribute mapping for related field 2014-04-24 15:58:53 +06:00
Ian Foote
853c7a16c1 Use setattr for adding fields to a new instance
Add test for restoring a GenericForeignKey
2014-04-13 17:33:45 +01:00
Xavier Ordoquy
d08536ad9d Merge remote-tracking branch 'origin/master' into 2.4.0
Conflicts:
	.travis.yml
	docs/api-guide/fields.md
	docs/api-guide/routers.md
	docs/topics/release-notes.md
	rest_framework/authentication.py
	rest_framework/serializers.py
	rest_framework/templatetags/rest_framework.py
	rest_framework/tests/test_authentication.py
	rest_framework/tests/test_filters.py
	rest_framework/tests/test_hyperlinkedserializers.py
	rest_framework/tests/test_serializer.py
	rest_framework/tests/test_testing.py
	rest_framework/utils/encoders.py
	tox.ini
2014-04-13 00:05:57 +02:00
Ian Foote
0a0e4f22e7 Set GenericForeignKey fields on object before save
* A model with a required GenericForeignKey can be saved if the field is set
2014-04-12 17:51:02 +01:00
Xavier Ordoquy
73cd4e236f Merge pull request #1477 from vlastv/patch-1
Writable star source with instance
2014-03-31 07:49:23 +02:00
Emanuele Pucciarelli
ab5082d15c Do not check model_field's attributes if it is None 2014-03-28 19:42:46 +01:00
Emanuele Pucciarelli
04315c12af Use help_text, verbose_name, editable attributes for related fields 2014-03-24 19:25:28 +01:00
Tom Christie
58cae22970 Merge pull request #1474 from elmehdikarami/master
Update serializers.py
2014-03-20 16:08:10 +00:00
Vladislav Vlastovskiy
e8167f96e6 Fixed copy-paste 2014-03-20 08:53:41 +04:00
Vladislav Vlastovskiy
c3aa10e589 Moved get component from object after test source is star 2014-03-20 01:50:40 +04:00
elmkarami
499d3cb8f0 Update serializers.py 2014-03-19 17:23:15 +00:00
elmkarami
03f96988ba Update serializers.py
Prevent iterating over a string that is supposed to be an iterable <==> Prevent read_only_fields = ('some_string)
2014-03-19 17:11:44 +00:00
elmkarami
5c87db96c5 Update serializers.py
Prevent iterating over a string that is supposed to be an iterable <==> Prevent read_only_fields = ('some_string)
2014-03-19 15:41:25 +00:00
Xavier Ordoquy
51e6982397 Fixed the validation for optional fields that have a value. 2014-03-06 21:18:37 +01:00
Rodolfo Carvalho
94fe03779b Fix typo 2014-03-05 17:01:54 +01:00
Carlton Gibson
95670933d7 Test and quick fix for #1257 2014-02-11 14:44:56 +01:00
juroe
b182b9e246 Fixes typo (Implicit instead of Implict). 2014-02-04 11:56:41 +01:00
Tom Christie
e9fda70b4a Nicer write_only fields implementation. Closes #1355 2014-01-15 08:53:23 +00:00
Tom Christie
8f6983ee6e Merge branch 'master' of git://github.com/sprymak/django-rest-framework into sprymak-master 2014-01-14 20:35:26 +00:00
Tom Christie
85d74fc86a Added write_only and write_only_fields. Refs #1306 2014-01-14 11:25:44 +00:00
S.Prymak
e9b0d70f5d Override HyperlinkedModelSerializerOptions url field name with URL_FIELD_NAME setting 2014-01-14 10:38:49 +02:00
Tom Christie
bc6c5df109 Minor tweaks 2014-01-13 17:39:22 +00:00
Dustin Farris
b1b58762a3 Move models.resolve_model to serializers._resolve_model 2014-01-13 11:47:44 -05:00
S.Prymak
65858428fd Make HyperlinkedModelSerializer url field name customizable 2014-01-13 16:35:20 +02:00
Dustin Farris
2332382b51 Add a sanity check to avoid running into unresolved related models. 2014-01-12 20:28:19 -05:00
Yuri Prezument
cd9a4194ea Check the modelfield's class instead 2014-01-12 16:32:36 +02:00
Yuri Prezument
e1bbe9d514 Set allow_none = True for CharFields with null=True 2014-01-12 10:53:54 +02:00
Steven Cummings
e020c51b44 FIX BaseSerializer.from_native has an altered signature
* base classes define it with one parameter
* BaseSerializer currently defines a second parameter, which we make optional here for method-dispatch passivity
2014-01-02 17:18:08 -06:00
S. Andrew Sheppard
d30ce2575c fix for genericrelation saving 2013-12-23 22:31:31 -06:00
Tom Christie
52686420f4 Merge branch 'bennbollay-patch-1' into 2.4.0
Conflicts:
	.travis.yml
	docs/api-guide/routers.md
	rest_framework/compat.py
	tox.ini
2013-12-23 09:48:59 +00:00
Tom Christie
a439c80cd8 Less brittle through relationship testing. Closes #1292. 2013-12-21 21:21:53 +00:00
Tom Christie
0f37260254 Merge pull request #1184 from dpetzel/nullbooleanfield_fix
Fix infered field type for models.NullBooleanField
2013-12-16 05:50:10 -08:00
Craig de Stigter
4a134eefa2 Fix expansion of writable nested serializers where the inner fields have source set. 2013-12-16 15:55:54 +13:00
Tom Christie
9c41c007af Merge branch 'master' into 2.4.0
Conflicts:
	.travis.yml
	docs/api-guide/routers.md
	docs/topics/release-notes.md
	rest_framework/compat.py
2013-12-13 16:32:34 +00:00
Tom Christie
0453cbd56b Clean up implementation 2013-12-13 11:09:54 +00:00
Tom Christie
a129bdd0f0 Merge pull request #1234 from linovia/bugfix/nested_models_without_related_name
Fixed the nested model serializers in case of the related_name isn’t set...
2013-12-13 03:06:14 -08:00
Tom Christie
3a1c40f814 Refine model manager behavior so as not to use the behavior in incorrect cases. Closes #1205 2013-12-10 08:46:44 +00:00
Chuck Harmston
cf6c11bd4b Raise appropriate error in serializer when making a partial update to set a required RelatedField to null (issue #1158) 2013-12-06 14:00:23 -06:00
Xavier Ordoquy
a8b15f4290 Another fix for nested writable serializers in case of the related_name isn’t set on the ForeignKey. 2013-11-18 15:11:29 +01:00
Xavier Ordoquy
ad7aa8fe48 Fixed the nested model serializers in case of the related_name isn’t set. 2013-11-17 01:27:16 +01:00
Doğan Çeçen
fd2c291c4d Typo on api-guide/fields.md and serializers.py 2013-11-11 11:54:30 +02:00
Tom Christie
470134ae9b Merge pull request #1217 from benpbenp/master
Fix object creation with reverse M2M when related_name unspecified
2013-11-08 07:15:40 -08:00
Ben Pietravalle
b7b57adee2 Fix object creation with reverse M2M when related_name unspecified
It seems that field.related_query_name() does not return the related_name
for reverse M2M relations when related_name is not explicitly set in the M2M field
definition.

So, change to use obj.get_accessor_name(), where obj is an instance of
RelatedObject, as are returned by a model's
_meta.get_all_related_many_to_many_objects(), or as in the tuples returned by
_meta.get_all_m2m_objects_with_model().
2013-11-08 13:19:40 +00:00
Xavier Ordoquy
d4a50429b0 Fixed a regression with ValidationError under Django 1.6 2013-11-08 13:12:40 +01:00
Mathieu Pillard
5325890821 Improve handling of 'empty' values for ChoiceField
The empty value defaults back to '' (for backwards-compatibility) but
is changed automatically to None for ModelSerializers if the `null`
property is set on the db field.
2013-11-05 17:21:18 +01:00
dpetzel
17a00be830 This fix results in models.NullBooleanField rendering as a checkbox in the browsable API 2013-10-18 21:13:20 -04:00
Tom Christie
2394f05e5a Merge pull request #1170 from craigds/write-into-foreignkey-with-source
fix writing into foreign key with non-null source
2013-10-17 07:59:29 -07:00
Tom Christie
6a40202a64 Merge pull request #1112 from tamakisquare/issue-1111
Test case and fix for issue 1111
2013-10-17 07:31:15 -07:00
Bruno Renié
cc3c16eaa0 Fix a docstring to reflect what the method does 2013-10-17 16:08:17 +02:00
Colin Huang
c6be12f02b [Fix]: Error with partial=True and validate_<name>
The error occurs when serializer is set with partial=True and a
field-level validation is defined on a field, for which there's no
corresponding update value in .data
2013-10-15 17:05:10 -07:00