Commit Graph

473 Commits

Author SHA1 Message Date
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
Craig de Stigter
7c3769f04b fix writing into foreign key with non-null source 2013-10-11 15:31:55 +13:00
Tom Christie
f18158358d Merge branch 'master' of https://github.com/tomchristie/django-rest-framework 2013-10-10 17:34:15 +01:00
Tom Christie
9e29c63895 Ensure read-only fields don't break with current HTML renderer behavior 2013-10-10 17:33:22 +01:00
Carlton Gibson
0bbc775b95 Merge pull request #1071 from craigds/field-transform-methods
Feature: add transform_<fieldname> methods to serializers
2013-10-09 01:11:46 -07:00
Tom Christie
8d4ba478cc Fix rendering of forms and add error rendering on HTML form 2013-10-02 16:13:34 +01:00
Tom Christie
a14f1e8864 Serializers can now be rendered directly to HTML 2013-10-02 13:45:35 +01:00
Tom Christie
e441f85109 Drop 1.3 support 2013-09-25 10:30:04 +01:00
Carlton Gibson
f07a4f4ca3 Clear cached serializer data on save() + test. Fixes #1116. 2013-09-20 14:10:46 +02:00
Tom Christie
9a5b2eefa9 Merge master 2013-08-30 09:28:33 +01:00
Tom Christie
3fba60e99c Drop broken placeholder serializations. 2013-08-30 09:02:54 +01:00
Craig de Stigter
94cd136943 add transform_<fieldname> methods to serializers, which basically do the opposite of validate_<fieldname> on a per-field basis. 2013-08-29 17:35:15 +12:00
Tom Christie
18007d6846 Simplifying raw data renderering support 2013-08-28 21:52:56 +01:00
Tom Christie
8d590ebfde First hacky pass at displaying raw data 2013-08-27 11:22:19 +01:00
Tom Christie
ab68d355f5 Merge pull request #1058 from ericbuehl/master
parameterize identity field serializer class to allow for easier subclassing
2013-08-25 12:46:11 -07:00
Eric Buehl
9d3fae27fd parameterize identity field class to allow for easier subclassing 2013-08-23 16:48:32 +00:00
Tom Christie
10d386ec6a Cleanup and dealing with empty form data. 2013-08-23 16:10:20 +01:00
Tom Christie
b72a99fef2 Merge branch 'display-nested-data' into html-form-renderer 2013-08-23 14:39:52 +01:00
Tom Christie
e03854ba6a Tweaks to display nested data in empty serializers 2013-08-23 14:06:14 +01:00
Tom Christie
28e44efe25 Merge branch 'master' into 2.4.0 2013-08-19 20:58:28 +01:00
Yuri Prezument
ff1efcf60f If null or blank - don't save the nested object 2013-08-12 21:06:37 +03:00
Tom Christie
fbd4c4ee8f Merge pull request #1030 from etos/patch-2
Spelling correction on read_only_fields err msg
2013-08-12 01:25:36 -07:00
Dan Stephenson
bbdcbe9452 Spelling correction on read_only_fields err msg
just spotted extras
2013-08-10 01:22:47 +01:00
Dan Stephenson
edd696292c Spelling correction on read_only_fields err msg 2013-08-10 01:12:36 +01:00
Kevin Brown
103fed9667 Fixed reversed arguments in assertion 2013-07-26 10:59:51 -04:00
Tom Christie
58d38d694e Merge branch 'master' into writable-nested-modelserializer 2013-06-28 09:07:09 +01:00
Tom Christie
379ad8a824 pending deprecations -> deprecated 2013-06-27 20:36:14 +01:00
Tom Christie
3fcc01273c Remove deprecated code 2013-06-27 20:29:52 +01:00
Tom Christie
69e5e3cc0d Use timezone aware datetimes with oauth2 provider, when supported. Closes #947. 2013-06-26 21:18:13 +01:00
Tom Christie
4ad1094968 HyperlinkedModelSerializer supports overriding of 'url' field. Closes #936 2013-06-17 15:09:36 +01:00
Tom Christie
de00ec95c3 Merge master 2013-06-05 13:33:19 +01:00
Tom Christie
62e59f8277 Merge pull request #900 from copitux/fix-validation-layer
Bugfix: Fix run validation layer with invalid data
2013-06-03 00:49:02 -07:00
Tom Christie
8b73dce51d view_name argument to HyperlinkedModelSerializer is now properly enforced. Closes #471 2013-06-02 19:50:24 +01:00
Tom Christie
d7753123f6 HyperlinkedModelSerializer lookup_field option should apply to HyperlinkedIdentityField 2013-05-31 11:50:37 +01:00
David Medina
d11b55648c Bugfix: Fix run validation layer with invalid data 2013-05-29 12:55:42 +02:00
Pascal Borreli
8f35ac4f93 Fixed typos 2013-05-28 15:09:23 +01:00
Tom Christie
fcaee6e580 Clean up OPTIONS implementation 2013-05-24 23:44:23 +01:00
Tom Christie
760e8642bd Merge branch 'issue-192-expose-fields-for-options' of https://github.com/grimborg/django-rest-framework into improved-options-support 2013-05-24 21:21:56 +01:00
Oscar Vilaplana
a1deb5eac7 simplified, moved field humanizing to Field. broken tests 2013-05-23 08:26:55 +02:00
Tom Christie
cdc3c37465 Merge and styling fixes 2013-05-21 12:01:56 +01:00
Stephan Groß
025c40e7d5 Fix order for applying min_value to fields 2013-05-18 17:16:29 +02:00
Markus Törnqvist
48c1b2233b Merge branch 'master' into mjtorn-master
Conflicts:
	rest_framework/serializers.py
	rest_framework/tests/serializer.py

Fixed conflicts
2013-05-18 18:13:31 +03:00
Stephan Groß
0c81d04170 Add min_value=0 to autogenerated Pos..IntFields 2013-05-18 17:04:20 +02:00
Tom Christie
5f8d353f0b Rename has_user_through_model -> has_through_model 2013-05-18 15:25:49 +01:00
Tom Christie
e1a3cab400 Merge pull request #854 from ryankask/issue-775
All relations pointing to ManyToManyFields should default to read-only
2013-05-18 07:22:22 -07:00
Tom Christie
cc39b9c925 Merge pull request #858 from minddust/fix_710
Fix for #710
2013-05-18 07:19:52 -07:00
Stephan Groß
b7176065a9 Update getattr 2013-05-18 16:06:30 +02:00
Tom Christie
ea9a3d88bc Merge pull request #859 from craigds/master
fix for #765
2013-05-18 07:06:21 -07:00
Craig de Stigter
208bd991da when source='*' on a nested serializer, expand fields into outer serializer when writing. fixes #765 2013-05-18 15:23:43 +02:00
Stephan Groß
a71acc76d8 Fix for #710 2013-05-18 15:12:54 +02:00
Ryan Kaskel
0b84c5a0ac Merge latest changes from master. 2013-05-18 14:04:27 +01:00
Ryan Kaskel
770ed3de2e ToMany fields default to read-only if targeting ManyToManyField. 2013-05-18 13:11:40 +01:00
Pablo Recio
de5cc8de42 A model's field is required if is null or blank 2013-05-18 12:40:25 +02:00
Markus Törnqvist
85faebbb75 Merge branch 'mikee2185-master' into mjtorn-master
Conflicts:
	rest_framework/fields.py
	rest_framework/serializers.py
	rest_framework/tests/models.py
	rest_framework/tests/serializer.py

Fixed all the conflicts.
2013-05-18 13:24:36 +03:00
Tom Christie
af88a5b175 Test and fix which closes #652. 2013-05-15 14:25:25 +01:00
Tom Christie
d62414147f Fix assert messaging on fields/exclude checking. Closes #833 2013-05-14 17:53:37 +01:00
Tom Christie
0176a5391b Fix HyperlinkedModelSerializer not respecting lookup_fields 2013-05-09 17:09:40 +01:00
Mark Aaron Shirley
e550740b3d Merge remote-tracking branch 'upstream/master' into writable-nested-modelserializer
Conflicts:
	rest_framework/tests/relations_nested.py
2013-05-08 22:39:48 -07:00
Tom Christie
538d2e35e7 lookup_field on hyperlink serializers 2013-05-05 16:47:45 +01:00
Tom Christie
35f99cddc4 lookup_field on hyperlinked fields, and overriddable hyperlinked fields. Closes #688 2013-05-01 09:03:09 +01:00
Tom Christie
22af28d146 Merge master 2013-04-30 19:32:34 +01:00
Tom Christie
21ae3a6691 Drop out attribute 2013-04-30 08:24:33 +01:00
Tom Christie
53f9d4a380 fields shortcut on views 2013-04-29 13:20:15 +01:00
Tom Christie
dc7b1d6430 2.2's PendingDeprecationWarnings now become DeprecationWarnings. 2.3's PendingDeprecationWarnings added. 2013-04-29 12:45:00 +01:00
JC
8cbb715f4c Changed definition of NestedModelSerializer to correct depth handling 2013-04-27 13:23:55 -07:00
Tom Christie
d985aec3c9 DecimalField 2013-04-26 13:59:06 +01:00
Tom Christie
95abe6e844 Cleanup docstrings 2013-04-25 12:47:34 +01:00
Tom Christie
4bf1a09bae Ensure implementation of reverse relations in 'fields' is backwards compatible 2013-04-23 11:31:38 +01:00
Mark Aaron Shirley
7e0a93f0ee Don't use field when saving related data 2013-04-19 10:46:57 -07:00
Mark Aaron Shirley
fdc5cc3d81 Fix model serializer nestesd delete behavior 2013-04-18 10:28:20 -07:00
Mark Aaron Shirley
c7e000e46e Merge remote-tracking branch 'upstream/master' into writable-nested-modelserializer
Conflicts:
	docs/api-guide/serializers.md
2013-04-16 09:55:47 -07:00
Stephan Groß
c329d2f085 Add DecimalField to field_mapping 2013-04-15 13:11:41 +02:00
Tom Christie
76e039d70e First pass on automatically including reverse relationship 2013-04-10 22:38:02 +01:00
Mark Aaron Shirley
73efa96de9 one-many writable nested modelserializer support 2013-04-06 08:43:21 -07:00
J. Paul Reed
889558365b Don't have the ModelSerializer trust deserialized objects to not have redefine bool()ean-ness.
If the model we're using the ModelSerializer for has redefined methods that act as a boolean (__bool__ or __len__), it may not return the object even though it is_valid(), and should.
2013-04-02 01:41:40 -07:00
Tom Christie
7eefcf7e53 Bulk update, allow_add_remove flag 2013-03-25 20:26:34 +00:00
Tom Christie
d97e72cdb2 Cleanup one-one nested tests and implementation 2013-03-25 17:28:23 +00:00
Tom Christie
3f79a9a3d3 one-one writable nested modelserializers 2013-03-22 22:39:45 +00:00
Tom Christie
addf7e9b36 Defer the writable nested modelserializers work 2013-03-22 22:27:03 +00:00
Tom Christie
9bf7c9b714 Merge master 2013-03-22 21:57:37 +00:00
Tom Christie
13794baf70 Bit of extra tidying and plenty of docs 2013-03-22 17:01:06 +00:00
Tom Christie
c32d9969ac Add extra tests for errors from incorrect data with multiple create/update 2013-03-22 12:33:09 +00:00
Tom Christie
b2dc664485 Basic bulk create and bulk update 2013-03-19 14:26:48 +00:00
Craig de Stigter
101fa26ebc use writablefield style for serializer handling of self.default 2013-03-18 16:05:34 +13:00
Craig de Stigter
d6d5b1d82a allow default values in writable serializer fields 2013-03-18 14:50:21 +13:00
Craig de Stigter
c8416df0c4 accept all WritableField kwargs for writable serializers (eg required=True) 2013-03-18 14:27:15 +13:00
Tom Christie
66bdd608e1 Fixes to save_object 2013-03-16 07:35:44 +00:00
Tom Christie
3ff103ad04 Fixes to save_object 2013-03-16 07:35:27 +00:00
Tom Christie
ccf551201f Clean up and comment restore_object 2013-03-16 07:32:50 +00:00
Tom Christie
56653111a6 Remove unneeded arguments to save_object 2013-03-15 19:57:57 +00:00
Tom Christie
32e0e5e18c Remove erronous _delete attribute 2013-03-15 19:55:32 +00:00
Tom Christie
47492e3ef4 Clean out ModelSerializer special casing from Serializer.field_from_native 2013-03-15 19:22:31 +00:00
Tom Christie
fb3b57803f one 2 one nested relationships 2013-03-15 19:17:54 +00:00
Mark Aaron Shirley
3006e3825f One-to-one writable, nested serializer support 2013-03-14 15:17:13 -07:00
Tom Christie
acc8c1faa4 force_insert, force_update arguments. Closes #484.
Confirmed by `assertNumQueries(…)` in tests.
2013-03-13 20:40:39 +00:00
Tom Christie
2f1951910f Descriptive text for NestedValidationError 2013-03-12 18:35:20 +00:00
Tom Christie
6b4bb48dd4 Initial support for writable nested serialization (Not ModelSerializer) 2013-03-12 13:33:02 +00:00
Mjumbe Wawatu Ukweli
bdcecf48e3 Simplify inherited child check to not use isinstance 2013-03-11 16:01:19 -04:00
Mjumbe Wawatu Ukweli
e7e470739f Use parent's primary key when model is derived via multitable inheritance 2013-03-11 03:23:44 -04:00
Tom Christie
239758e034 Serializers support bulk create. 2013-03-09 10:21:53 +00:00
Tom Christie
28ae26466e Py3k fixes. 2013-03-08 22:43:46 +00:00
Tom Christie
68683b2ea2 Tweak implementation, and use FormSet style errors 2013-03-08 22:19:09 +00:00
Ian Dash
66605acaf0 Errors during deserializing lists now return a list of tuples with
index of bad item in data plus usual errors dict
2013-03-08 15:08:05 +00:00
Tom Christie
183d3ec6a4 Move ModelSerializer field_mapping into an attribute for easier overriding. 2013-02-28 13:41:42 +00:00
Danilo Bargen
e476dcb8c7 Changed AttributeError to AssertionError 2013-02-26 09:38:57 +01:00
Danilo Bargen
ec4d79bcaf Show class name in exception message 2013-02-25 23:02:42 +01:00
Danilo Bargen
3e6f99e273 Improved exception message for missing serializer model meta option 2013-02-25 22:34:05 +01:00
Tom Christie
e1f0001f92 Fix and test for #645
Yuck, pickle is weird.  Closes #645.
2013-02-22 23:00:07 +00:00
Tom Christie
bba918fb2a Fix and test case for #653
Closes #653
2013-02-22 22:13:06 +00:00
Tom Christie
bc87bf13b4 Tests and fix for #666.
Closes #666.
2013-02-22 22:02:42 +00:00
Andreas Pelme
5a5df18d18 Added a serializer TimeField 2013-02-14 21:19:51 +01:00
Tom Christie
24ed0fa4b9 Drop accidental (uneeded) validation logic. 2013-02-14 12:26:02 +00:00
Tom Christie
7f797abc19 Remove deprecated APIs from tests 2013-02-12 20:07:35 +00:00
Tom Christie
388e617366 Raise warnings on implicit many serialization 2013-02-12 13:53:45 +00:00
Tom Christie
aa03425c09 Merge pull request #651 from fernandogrd/master
DictWithMetadata.__getstate__ was never called (Fix for 645)
2013-02-11 23:27:35 -08:00
Fernando Rocha
ea004b5e7a Make use o issubclass instead of isinstance (fix issue #645)
Because __mro__ is a list of classes and not instances.
DictWithMetadata.__getstate__ was never called

Signed-off-by: Fernando Rocha <fernandogrd@gmail.com>
2013-02-11 19:18:22 -03:00
Tom Christie
670ac25b25 Allow serializers to handle dicts as well as objects. Fixes #447. 2013-02-07 12:57:40 +00:00
Tom Christie
8113d66126 Use new style of required=<bool> not blank or null 2013-02-07 09:24:34 +00:00
Tom Christie
5813a09512 Use new many=True relations style. 2013-02-07 09:14:58 +00:00
Tom Christie
efb798cebc Don't deprecate 'exclude'
Need to track outcome of Django's #19733, and decide on approach
accordingly.
2013-02-06 08:48:41 +00:00
Tom Christie
7dc4bce4e2 Fix 2.6 compat 2013-02-04 21:35:47 +00:00
Tom Christie
b052c92ac3 Cleanup imports
Mostly adding `from __future__ import unicode_literals` everywhere.
2013-02-04 20:55:35 +00:00
Tom Christie
8e846bdf52 Merge branch 'py3k' into 2.2
Conflicts:
	rest_framework/relations.py
	rest_framework/serializers.py
	rest_framework/tests/relations_hyperlink.py
	rest_framework/tests/relations_slug.py
2013-02-04 20:37:09 +00:00
Tom Christie
f4f237e3ee 3.2, 3.3 compat 2013-02-01 14:03:28 +00:00
Tom Christie
d9c7b1c585 Merge branch 'p3k' of https://github.com/linovia/django-rest-framework into working
Conflicts:
	rest_framework/authentication.py
	rest_framework/relations.py
	rest_framework/serializers.py
	rest_framework/settings.py
	rest_framework/tests/authentication.py
	rest_framework/tests/genericrelations.py
	rest_framework/tests/generics.py
	rest_framework/tests/relations_hyperlink.py
	rest_framework/tests/relations_nested.py
	rest_framework/tests/relations_pk.py
	rest_framework/tests/serializer.py
2013-02-01 11:58:55 +00:00
Tom Christie
d9b73e15c8 Serializers take many=<bool> argument. 2013-01-31 17:06:23 +00:00
Tom Christie
f1e665673f Tidying 2013-01-30 20:38:11 +00:00
Tom Christie
be6df3ae3c Merge branch 'master' into many-fields
Conflicts:
	rest_framework/relations.py
2013-01-30 13:41:56 +00:00
Andrea de Marco
85e6360792 Update rest_framework/serializers.py 2013-01-28 22:08:40 +01:00
Tom Christie
a3a06d11cc Ensure model field validation is performed for ModelSerializers with a custom restore_object method. Fixes #623. 2013-01-28 12:56:42 +00:00
Tom Christie
a51bca32fd Fix issues with custom pagination serializers 2013-01-26 20:54:41 +00:00
Tom Christie
b41f258ee5 Serializers should accept source='*' argument. Fixes #604.
(Test also incoming)
2013-01-26 20:54:03 +00:00
Stephan Groß
69e62457ef Improve validate_<fieldname> fix 2013-01-23 07:53:54 +01:00
Stephan Groß
2250ab6418 Add possible solution for field validation error 2013-01-21 12:50:39 +01:00
Tom Christie
6385ac519d Revert accidental merge. 2013-01-18 19:47:57 +00:00
Mark Aaron Shirley
221f7326c7 Use None to delete nested object as opposed to _delete flag 2013-01-16 16:04:20 -08:00
Mark Aaron Shirley
34e14b01e4 Move nested serializer logic into .field_from_native() 2013-01-16 16:04:20 -08:00
Mark Aaron Shirley
2d62bcd5aa Add one-to-one nested update and delete functionality 2013-01-16 16:04:20 -08:00
Mark Aaron Shirley
72c04d570d Add nested create for 1to1 reverse relationships 2013-01-16 16:04:19 -08:00
Tom Christie
d9acec3e6d PK fields should only be read-only if they are an AutoField. Fixes #563 2013-01-12 09:43:14 +00:00
Tom Christie
73c4e5c460 auto_now and auto_now_add fields should be read only by default 2013-01-12 09:43:14 +00:00
Mark Aaron Shirley
81691ff900 Merge remote-tracking branch 'upstream/master' into null-one-to-one 2013-01-08 08:33:01 -08:00
Tom Christie
4bb504732d Respect blank=True on relational fields. Fixes #537 2013-01-07 21:08:55 +00:00
Mark Aaron Shirley
213981cef3 Handle ObjectDoesNotExist exceptions when serializing null reverse one-to-one 2013-01-04 21:11:03 +01:00
Tom Christie
26f9acb45a Validation errors instead of exceptions when serializers receive incorrect types. Fixes #402. 2013-01-04 14:11:05 +00:00
Tom Christie
92ae08207a Drop unused private save_m2m flag 2013-01-03 21:49:01 +00:00
Xavier Ordoquy
60250f22c8 Move the various compat things to the compat module. 2013-01-03 11:41:07 +01:00
Xavier Ordoquy
c95fa81cb2 Use new exception style 2013-01-02 19:06:28 +01:00
Xavier Ordoquy
737349d238 Merge remote-tracking branch 'reference/py3k' into p3k 2013-01-02 16:09:21 +01:00
Mark Aaron Shirley
a617a3758f Don't persist relation changes in ModelSerializer#restore_object() 2012-12-31 14:33:24 +01:00
Tom Christie
8fad0a727a Relation fields move into relations.py 2012-12-31 08:53:40 +00:00
Tom Christie
caaf1c80f5 Support reverse FK creation 2012-12-29 16:51:41 +00:00
Tom Christie
809f5de330 Merge pull request #515 from yprez/blank_fields_issue
Fix for #514
2012-12-29 05:25:43 -08:00
Tom Christie
923f81d269 Nested serializers now support nullable relationships, plus test. Fixes #384 2012-12-29 13:19:05 +00:00
Michal Dvorak (cen38289)
5ba2437f2d Merge remote-tracking branch 'tom/master'
Conflicts:
	rest_framework/tests/serializer.py
2012-12-21 10:53:23 +01:00
Tom Christie
6693d2d277 Fix for pks returning as strings when set in pre_save. Fixes #482. Thanks to @n8agrin for the bug report. 2012-12-18 18:21:58 +00:00
Tom Christie
aa72f8d63d Fix bug with M2M in browseable API 2012-12-17 21:59:51 +00:00
Michal Dvorak (cen38289)
8ac77eaae8 Merge remote-tracking branch 'tom/master'
Conflicts:
	rest_framework/serializers.py
	rest_framework/tests/serializer.py
2012-12-17 17:01:00 +01:00
Yuri Prezument
c68f7ca580 blank=True fields are not required - fixes #514 2012-12-17 16:57:11 +02:00
toran billups
008dafce17 ManyPrimaryKeyRelatedField now supports create for one-to-many rel 2012-12-15 20:55:36 -06:00
Tom Christie
35f72cecb1 Fix model validation exclusions. Fixes #500. Fixes #506. 2012-12-15 20:40:41 +00:00
Tom Christie
39b01d6802 Ensure context is passed to dynamically added fields. Fixes #476. 2012-12-14 19:59:29 +00:00
Tom Christie
497da7fc69 Clean up field initialization. Fixes #497 2012-12-12 20:45:06 +00:00
Tom Christie
85bf4164dd Drop left over code 2012-12-11 22:09:04 +00:00
Tom Christie
4058223309 Fix broken nested fields 2012-12-11 21:07:25 +00:00
Marko Tibold
d0935d1fbb get_excluded_fieldnames() should respect Meta options' ability to be either a tuple or list. Fixes #490.
Refactored `if self.opt.fields` out of the for loop.
Updated and cleaned up the validation-tests.
2012-12-10 23:10:04 +01:00
Tom Christie
ac2720afcb Add null related field option 2012-12-08 13:00:49 +00:00
Tom Christie
303bc7cf95 Support nullable FKs, with blank=True 2012-12-07 21:32:45 +00:00
Tom Christie
a5178e9a36 Merge pull request #451 from markotibold/#431
Call model's .full_clean() method, eg. to validate uniqueness
2012-12-07 12:34:56 -08:00
Marko Tibold
919aff329e Fix AttributeError caused by accessing a non-existing default_keys attribute. 2012-12-07 00:08:27 +01:00
Tom Christie
6ffcd7ba36 Merge pull request #477 from roberts81/master
Fix for #460
2012-12-06 14:54:28 -08:00
Marko Tibold
c65f22e0e4 Merge branch 'master' of https://github.com/tomchristie/django-rest-framework into #431 2012-12-06 23:47:47 +01:00
Ben Roberts
cb7d9ea5c9 cleaned up white space & docstring styling 2012-12-06 12:45:50 -07:00
Ben Roberts
705c7ad09d added tests and fix for unpickleable metadata in SortedDictWithMetadata 2012-12-05 17:43:47 -07:00
Michal Dvorak (cen38289)
2a82b64963 Moved smart_unicode to Field ctor, to mimic Django Forms behavior. 2012-12-04 14:22:41 +01:00
Michal Dvorak
ad01fa0eae #467 Added unit test 2012-12-03 19:07:07 +01:00
Michal Dvorak (cen38289)
9ae0ca1cae #467 Added label and help_text to Field 2012-12-03 17:26:01 +01:00
Xavier Ordoquy
5fad46d7e2 Merge remote-tracking branch 'reference/master' into p3k 2012-12-02 12:43:32 +01:00
Pavel Savchenko
e311b763e1 add traverse_related feature + tests (fixes issue#461) 2012-11-30 01:34:46 +02:00
Marko Tibold
899f96ae91 Added a get_excluded_fieldnames() method.
Model validation now excludes fields not listed in Meta fields (if set).
2012-11-27 23:49:27 +01:00
Marko Tibold
f104f74340 Moved model validation from .perform_validation() to .validate() 2012-11-27 23:21:12 +01:00
Tom Christie
7ade5add21 Merge pull request #439 from irrelative/master
Cache all fields per serializer instance
2012-11-22 16:17:47 -08:00
Marko Tibold
bd8c742df2 Cleanup. 2012-11-22 23:39:16 +01:00
Marko Tibold
ca5b99486d Added _post_clean() behaviour by adding a .perform_model_validation() method.
Fixed some tests that were failing due to extra strict validation.
2012-11-22 22:36:37 +01:00
jedavis83@gmail.com
2e36e0c910 Remove unneeded and incorrect self reference 2012-11-22 12:22:30 -08:00
jedavis83@gmail.com
08e7818530 More consistent iteration over default_fields, per feedback. 2012-11-22 11:27:55 -08:00
jedavis83@gmail.com
e9944f82d1 Keep Serializer.fields API consistent while caching values. 2012-11-22 10:50:29 -08:00
Xavier Ordoquy
4007b56457 28 tests passes now. 2012-11-22 08:30:32 +01:00
Mark Aaron Shirley
0876bed963 Merge remote-tracking branch 'upstream/master' into partial-update 2012-11-21 09:37:22 -08:00
Stephan Groß
774d687a31 updated comparison due to pep8 programming recommendations
http://www.python.org/dev/peps/pep-0008/#programming-recommendations
2012-11-21 14:58:33 +01:00
jedavis83@gmail.com
8b0561c57e Cache all fields on serializer init, not just default fields. 2012-11-20 23:09:47 -08:00
Tom Christie
9b63ba3800 Merge pull request #433 from irrelative/master
Cache default_fields per serializer instance for faster serialization
2012-11-20 15:13:30 -08:00
Mark Aaron Shirley
c3644234cd Add support for partial serializer updates 2012-11-20 11:01:21 -08:00
Jamie Matthews
68c397371c Fix related serializers with source argument that resolves to a callable 2012-11-20 09:41:36 +00:00
jedavis83@gmail.com
2cf0fda2ae Cache default fields per serializer instance for improved performance 2012-11-19 22:09:40 -08:00
Tom Christie
e801e21210 Merge pull request #422 from markotibold/max_length_for_modelserializers
Max length for modelserializers
2012-11-16 14:54:16 -08:00
Marko Tibold
1a436dd6d9 Added URLField and SlugField.
Fixed test_modelserializer_max_length_exceeded
2012-11-16 22:43:16 +01:00
Marko Tibold
f385b72d80 Whoops … Drop pdb 2012-11-16 22:20:26 +01:00
Marko Tibold
aa013a4289 Fixes #421 2012-11-16 22:18:57 +01:00
Marko Tibold
403886b79b Merge commit '3b258d69c92e9d9293f7c5d1690f0ca434e677e3' into file_and_image_fields 2012-11-15 22:48:22 +01:00
Marko Tibold
c35b9eb065 Processed review comments.
No type checking in .restore_fields()
Added missing BytesIO import.
2012-11-14 21:13:23 +01:00
Stephan Groß
44ff2e0add fixed some typos 2012-11-14 19:36:29 +01:00
Marko Tibold
5443dd5f3c Added a FileField and an ImageField (copied from django.forms.fields).
Adjusted generics, mixins and serializers to take a `files` arg where applicable.
2012-11-13 23:26:17 +01:00
Tom Christie
21468a1867 Fix broken depth argument 2012-11-13 11:47:32 +00:00
Tom Christie
e224061189 Support for read_only_fields on ModelSerializer classes 2012-11-09 17:01:20 +00:00
Tomi Pajunen
40c6fe7119 Comments updated 2012-11-08 17:04:29 +02:00
Tomi Pajunen
743224d000 Fixed creation of objects with reversed M2M relations 2012-11-08 16:31:16 +02:00
Toni
5d69628250 Update rest_framework/serializers.py
fixed AttributeError in case restore_object is overwritten without explicitly setting self.m2m_data
2012-11-05 20:55:03 +01:00
Tom Christie
6d201c362f Drop unneccesarily lenient dictionary-containing-instances serialization. 2012-11-05 16:19:11 +00:00
Tom Christie
33be4b43b9 queryset argument is now optional on writable model fields. 2012-11-05 12:51:04 +00:00
Tom Christie
ccd5f29510 Tidy up serializer fields now we no longer use dynamic fields 2012-11-05 11:03:36 +00:00
Tom Christie
dfb8225447 Add note on * import 2012-11-05 10:56:30 +00:00
Tom Christie
b7b942c599 Swap position of instance and data keyword arguments. 2012-11-05 10:53:20 +00:00
Tom Christie
0047a46020 Merge fixes for 'blank=True' fields. Fixes #324, Fixes #325
Thanks to @Roarster.
2012-10-30 11:03:03 +00:00
Tom Christie
e5777a6168 Merge pull request #336 from markotibold/null_is_true_model_fields
Null is true model fields
2012-10-30 02:22:51 -07:00
Marko Tibold
4d90bb4af4 Fix some typos. 2012-10-30 00:30:52 +01:00
Marko Tibold
2068595297 Set a ModelSerializer field to required=False if the ModelField has null=True set. 2012-10-30 00:09:40 +01:00
Tom Christie
de6908fbef Remove recursion detection 2012-10-28 20:50:14 +00:00
Tom Christie
351382fe35 nested -> depth 2012-10-28 20:43:43 +00:00
Tom Christie
44207a347a pep8 2012-10-27 10:33:01 +01:00
Tom Christie
67f1265e49 Fix failing 'default' on ModelSerializer 2012-10-26 13:20:30 +01:00
Tom Christie
32d602880f Choice fields from ModelSerializer. 2012-10-26 12:45:52 +01:00
Tom Christie
3e751ccd8a Fix ModelSerializer logic for fields with default value, which should have required=False set 2012-10-24 20:58:28 +01:00
Jamie Matthews
607c31c6d8 Move per-field and cross-field validation into a single method 2012-10-24 12:12:27 +01:00
Jamie Matthews
d60d598e02 Clean up internal names and documentation 2012-10-24 11:43:30 +01:00
Jamie Matthews
ac2d39892d Add cross-field validate method 2012-10-24 11:39:17 +01:00
Jamie Matthews
388a807f64 Switch from clean_<fieldname> to validate_<fieldname>, clarify documentation 2012-10-24 11:27:01 +01:00
Jamie Matthews
51fae73f3d Implement per-field validation on Serializers 2012-10-24 09:28:10 +01:00
Jamie Matthews
45d4622f09 Fix serialization of reverse relationships 2012-10-22 15:12:25 +01:00
Rob Dobson
38673c35d4 Make default field check safe for boolean values whereby 'False' may be an acceptable default value 2012-10-17 19:12:34 +01:00
Jens Alm
c942726509 Added docs, integer fields and refactored models.TextField to use CharField
I realized that per the django forms, there is no need for a separate
TextField, an unlimited CharField is perfectly good.
Also added default field for the different IntegerField types
2012-10-15 13:46:44 +02:00
Jens Alm
36cc56bc9d Added tests for TextField 2012-10-15 10:06:50 +02:00
Jens Alm
241be38340 Added TextField to recognized fields 2012-10-15 09:14:01 +02:00