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
Tom Christie
83f39b3dce
Don't fail when no data provided
2012-10-10 16:41:08 +01:00
Tom Christie
a3ab66eca4
Add 'to_many' flag in get_related_field
2012-10-09 17:51:32 +01:00
Tom Christie
9bbc1cc403
Add flag in get_related_field
2012-10-09 17:49:04 +01:00
Tom Christie
65f592866c
Fix issue where required fields were not being properly validated. Also make model fields with a default value be not required
2012-10-08 17:53:18 +01:00
Tom Christie
52ba2e3333
Fix #285
2012-10-08 12:52:56 +01:00
Tom Christie
c91d926b06
Initial tests for hyperlinked relationships
2012-10-04 16:58:18 +01:00
Tom Christie
aac6b6cf4e
Tweak comment
2012-10-04 15:00:23 +01:00
Tom Christie
3a06dde884
Clean up field classes
2012-10-04 13:28:14 +01:00
Tom Christie
d89d6887d2
HyperlinkedModelSerializer with working HyperlinkedIdentityField, but no hyperlinked relations
2012-10-04 11:26:41 +01:00
Tom Christie
a366d6e612
M2M fields supported
2012-10-03 16:08:20 +01:00
Tom Christie
58c1263267
Use either PrimaryKeyRelatedField or ManyPrimaryKeyRelatedField as appropriate (fixes test)
2012-10-03 12:16:30 +01:00
Tom Christie
7c303411a9
Add Serializer.save() to clean up differences between serializer.object being either a DeserializedObject or a model instance
2012-10-03 11:08:02 +01:00
Tom Christie
1a05942166
Stopgap fix for model fields rendering in browseable API
2012-10-03 09:45:27 +01:00
Tom Christie
c30e0795be
Rename generic views
2012-10-03 09:26:15 +01:00
Tom Christie
d1b99f350a
Added model form field -> serializer form field mapping
2012-10-02 16:16:49 +01:00
Tom Christie
ab173fd8f9
Fix bug where pk could be set in post data
2012-10-02 15:37:13 +01:00
Tom Christie
b16fb57771
Expand pagination support, add docs
2012-10-01 15:49:19 +01:00
Tom Christie
9f71f8e618
Fix broken bits of generic views
2012-09-28 15:54:00 +01:00
Tom Christie
4ebd701be7
Fix serialization issue with Django 1.3
2012-09-28 14:53:22 +01:00
Tom Christie
e003cc91b6
Get test-only models properly working
2012-09-28 14:28:50 +01:00
Tom Christie
e0913e29b8
Fix some bits of serialization
2012-09-25 13:20:12 +01:00
Tom Christie
d9cba6398e
Clean up bits of templates etc
2012-09-20 17:44:34 +01:00
Tom Christie
4b691c4027
Change package name: djangorestframework -> rest_framework
2012-09-20 13:06:27 +01:00