Commit Graph

362 Commits

Author SHA1 Message Date
Tom Christie
79715f01f8 Coerce dates etc to ISO_8601 in seralizer, by default. 2014-09-12 12:10:22 +01:00
Tom Christie
5e39e159ee UNICODE_JSON and COMPACT_JSON settings 2014-09-12 11:38:22 +01:00
Tom Christie
250755def7 Clean up relational fields queryset usage 2014-09-12 10:59:51 +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
1e53eb0aa2 DecimalFields should still be quantized even without coerce_to_string 2014-09-11 21:57:32 +01:00
Tom Christie
040bfcc09c NotImplemented stubs for Field, and DecimalField improvements 2014-09-11 21:48:54 +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
Christopher Adams
613a301a36 Fixed #1533 - Resolved issue with integer keys on nested choices never validating.
- Added unit test for nested `choices` argument.
- Added unit test for non-nested `choices` argument.
2014-09-06 17:13:28 -04:00
Tom Christie
d934824bff Workin on 2014-09-05 16:29:46 +01:00
Piotr Jakimiak
c3b841ae44 Use Serializer instead of ModelSerializer 2014-09-05 14:08:11 +02:00
Piotr Jakimiak
6022b9ddd4 Fix comment 2014-09-05 12:00:17 +02:00
Piotr Jakimiak
d9633c6817 Fix returning None when allow_none is True in CharField 2014-09-05 11:08:34 +02: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
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
d2795dd26d Resolve linting issues 2014-08-19 13:54:52 +01:00
Xavier Ordoquy
4876bec9f5 Merge remote-tracking branch 'origin/master' into 2.4.0
Conflicts:
	rest_framework/fields.py
2014-07-26 00:06:56 +02:00
Serhiy Voyt
3326ddc865 Merge branch 'master' into modelserialization-charfield-with-null 2014-06-27 18:10:50 +03: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
TankorSmash
544183f64f typo in the docs 2014-06-16 19:13:02 -04:00
khamaileon
08c4594145 Replace ChoiceField type_label 2014-06-05 12:49:02 +02:00
John Spray
04c820b8e5 fields: allow help_text on SerializerMethodField
...by passing through any extra *args and **kwargs
to the parent constructor.

Previously one couldn't assign help_text to a
SerializerMethodField during construction.
2014-05-22 15:24:35 +01:00
Tom Christie
218b94e606 Merge pull request #1536 from Ian-Foote/choicefield_blank_display_value
Allow customising ChoiceField blank display value
2014-05-20 16:03:51 +01:00
Carlton Gibson
d69d975015 Merge pull request #1564 from alumni/master
Fixes #1535 (HTML widget missing `id` attribute)
2014-05-09 10:36:06 +02:00
Carlton Gibson
591d5240da Merge pull request #1575 from ewdicus/iso8601
Add colon to time zone offset in readable_datetime_formats
2014-05-08 09:34:06 +02:00
Elliott
11115fde9c Add colon to time zone offset in readable_datetime_formats 2014-05-07 11:37:20 -07:00
Serhiy Voyt
27be31bd8a In case of None value returns empty string instead of NoneType. 2014-05-07 18:37:08 +03:00
Serhiy Voyt
1ce1f387b0 Charfied from_native method returns default instead of None. Updated tests. 2014-05-06 21:57:25 +03:00
Lucian Mocanu
4e33ff05d9 Automatically set the field name as value for the HTML id attribute on the rendered widget. 2014-05-04 00:12:08 +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
Kamil Niski
82094554e5 Minor typo 2014-04-27 02:54:47 +02:00
Ian Foote
6c108c459d Allow customising ChoiceField blank display value 2014-04-16 12:32:04 +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
Mauro de Carvalho
2a1571b3bf Fixed comment. 2014-04-07 18:27:59 -03:00
Anton Shutik
1addd09e2b RelatedField default value handling fixed 2014-02-27 18:34:36 +03:00
Carlton Gibson
f1016441f5 Test and fix for #1210. World's lowest hanging fruit. 2014-02-11 19:52:32 +01:00
Tom Christie
e9fda70b4a Nicer write_only fields implementation. Closes #1355 2014-01-15 08:53:23 +00:00
Tom Christie
85d74fc86a Added write_only and write_only_fields. Refs #1306 2014-01-14 11:25:44 +00:00
Yuri Prezument
6e622d644c CharField - add allow_null argument 2014-01-12 10:53:54 +02:00
Yuri Prezument
e88e3c6ae1 Possible fix for #1330
Coerce None to '' in CharField.to_native()
2014-01-12 10:53:54 +02: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
Kevin Brown
90edcbf938 Fix default values always being False for browsable API
This fixes a bug that was introduced in 28ff6fb [1] for the
browsable API, specifically with how it handled default values
for boolean fields.  Previously, it had a global default for
boolean fields set to `False`, which was different than the
standard None that was used elsewhere.  Because this only needed
to be done for the browsable API, a fix was put into place that
only set the default to `False` when form data was passed into
the serializer.  This had the unintended side effect of overriding
any default set on the boolean field.

This fixes #1101 [2] by only overriding the default if the default is
`None`, which is the default for all fields.

[1]: 28ff6fb1ec
[2]: https://github.com/tomchristie/django-rest-framework/issues/1101
2013-12-13 13:20:29 -05: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
344cd865ab Merge pull request #1250 from Ian-Foote/choice_field
Add choices to options metadata for ChoiceField.
2013-12-03 08:03:02 -08:00
Omer Katz
b8f8fb7779 Updated the assertion message of the ImageField. 2013-11-27 13:26:49 +02:00
Ian Foote
8d09f56061 Add unittests for ChoiceField metadata.
Rename 'name' to 'display_name'.
2013-11-27 11:06:42 +00:00
Ian Foote
2484fc9141 Add more context to the ChoiceField metadata. 2013-11-26 17:10:16 +00:00
Ian Foote
a38d9d5b24 Add choices to options metadata for ChoiceField. 2013-11-26 09:33:47 +00: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
Tom Christie
c3e370b168 Merge branch 'html-form-rendering' 2013-10-10 17:33:39 +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
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
Philip Douglas
272a6abf91 Try a more localised fix to the data=None problem 2013-09-13 10:46:24 +01:00
Tom Christie
9a5b2eefa9 Merge master 2013-08-30 09:28:33 +01:00
Mathieu Pillard
11071499a7 Make ChoiceField.from_native() follow IntegerField behaviour on empty values 2013-08-29 18:10:47 +02:00
Tom Christie
47d17b088a Merge branch 'fix_937' of git://github.com/aburgel/django-rest-framework into aburgel-fix_937 2013-08-23 11:56:22 +01:00
Tom Christie
16ffdedd14 Merge master 2013-08-21 21:31:59 +01:00
Tom Christie
28ff6fb1ec Only HTML forms should have implicit default False for boolean fields 2013-08-19 21:44:47 +01:00
Tom Christie
28e44efe25 Merge branch 'master' into 2.4.0 2013-08-19 20:58:28 +01:00
JT
2f03870ae1 Fix for "No module named compat" 2013-08-13 18:48:49 -05:00
Alex Burgel
db9672d304 Add support for removing field files by sending an empty string 2013-07-24 17:24:29 -04:00
Pavel Zinovkin
2e18fbe373 Updated EmailField error message. This one already available in django translations.
https://github.com/django/django/blob/master/django/conf/locale/ru/LC_MESSAGES/django.po#L343
2013-07-21 17:03:58 +04:00
Tom Christie
8f79caf9d1 Use 'force_text', not 'unicode', for compat across python version 2013-07-05 09:07:18 +01:00
Andy Freeland
7d43f41e4a Remove 'Hold down "Control" ...' message from help_text
When getting the help_text from a field where `many=True`, Django
appends 'Hold down "Control", or "Command" on a Mac, to select more than
one.' to the help_text. This makes some sense in Django's ModelForms,
but no sense in the API.
2013-07-04 01:51:24 -04:00
Tom Christie
3fcc01273c Remove deprecated code 2013-06-27 20:29:52 +01:00
David Sanders
fcaca73709 Pep8 lint 2013-06-11 16:10:25 -06:00
David Sanders
656897c2da Update ModelField to work with a broader range of fields
Add support for fields that use min and max value validators.
2013-06-11 16:09:32 -06:00
Tom Christie
40e09472d8 Never deepcopy validators. Closes #913 2013-06-06 08:56:39 +01:00
Tom Christie
b15a6ccef2 Serializer field 'default' argument may be a callable 2013-06-02 20:12:49 +01:00
Gustavo Andrés Angulo
de1cc5f8c1 Fix default field when is a simple callable function. 2013-05-29 11:45:54 -05: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
David Jones
c3fd7c6685 Updated SlugField to raise validation errors for invalid slugs 2013-05-20 13:04:38 +01:00
Oscar Vilaplana
e80488b619 Added min_length and max_length 2013-05-19 15:08:41 +02:00
Oscar Vilaplana
696c053f4f s/Single Character/String/ 2013-05-19 15:04:43 +02:00
Oscar Vilaplana
b915c1d4d8 Made field label optional in OPTIONS 2013-05-19 11:15:38 +02:00
Nikolaus Schlemm
c0f3a1c397 Integrated status quo of grimborg's awesome humanize_field() for exposing field metadata via OPTIONS :) 2013-05-19 09:25:02 +02:00
Nikolaus Schlemm
9454e23aa9 Merge branch 'master' of git://github.com/tomchristie/django-rest-framework into issue-192-expose-fields-for-options 2013-05-19 09:02:07 +02:00
Nikolaus Schlemm
843ae60237 Merge branch 'issue-192-expose-fields-for-options' of git://github.com/grimborg/django-rest-framework into issue-192-expose-fields-for-options
Conflicts:
	rest_framework/tests/fields.py
2013-05-18 18:34:21 +02:00
Oscar Vilaplana
fecadacab1 added tests for form 2013-05-18 18:27:53 +02:00
Oscar Vilaplana
4dffcb5d77 Added humanized field names and types 2013-05-18 18:10:17 +02:00
Ryan Kaskel
579f77ceaa Move function to compat. 2013-05-18 17:04:17 +01:00
Ryan Kaskel
33f702d306 Merge latest changes from master. 2013-05-18 16:26:17 +01:00
Ryan Kaskel
10e451a85a Handle Python 3 strings and lazy strings. 2013-05-18 16:21:18 +01: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ß
9f9cb97d65 Add TestCases for default field values 2013-05-18 16:24:54 +02:00
Ryan Kaskel
22874e441d Merge latest changes from master. 2013-05-18 14:17:50 +01:00
Tom Christie
6d425aa3be Merge pull request #831 from brianz/master
Allow nested fields to be missing
2013-05-18 04:36:00 -07:00
Pablo Recio
53a8004401 Merge branch 'master' into 725-blank-choice-dash
Conflicts:
	rest_framework/tests/fields.py
2013-05-18 12:51:40 +02:00
Pablo Recio
ab8bd566f9 Adding BLANK_CHOICE_DASH as a choice if the model's field isn't required 2013-05-18 12:41:52 +02:00
Tom Christie
a73c16b85f serializers.Field respects ordering on dicts if it exists. Closes #832 2013-05-18 11:27:48 +01:00
Markus Törnqvist
3691cd2ffd Use smart_text() instead of nonexistant smart_unicode() 2013-05-18 13:26:59 +03: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
Brian Zambrano
24c9c455fe Allow for missing non-required nested objects.
Serializer fields which are themselves serializers should not be required.
Specifically, if a nested object is set to "required=False", it should be
possible to serialize the main object and have the sub-object set to None/null.
2013-05-13 14:41:12 -07:00
Tom Christie
b443560080 Fix DATETIME_FORMAT, DATE_FORMAT, TIME_FORMAT settings. Closes #798 2013-05-08 20:38:50 +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
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
Stephan Groß
cac6697025 Return Decimal instance instead of string 2013-04-15 15:24:14 +02:00
Stephan Groß
9d80f01bce Fix init call 2013-04-15 15:15:55 +02:00
Stephan Groß
ad436d966f Add DecimalField support 2013-04-15 13:02:18 +02:00
Matteo Suppo
b5640bb778 Forcing translations of lazy translatable strings in Field to_native method 2013-03-23 14:18:55 +01:00
Tom Christie
8adde506e8 Default date/time fields now return python date/time objects again by default 2013-03-21 08:41:54 +00:00
Tom Christie
20fd738c85 iso formated datetime aware fields with +0000 offset should use 'Z' suffix instead 2013-03-20 13:05:59 +00:00
Tom Christie
a798a5350a Fix duplicated database queries for paginated lists.
Closes #713.
2013-03-13 11:42:12 +00:00
Tom Christie
ad336cc636 Fix broken None value for TimeField.
Refs #707.
2013-03-07 09:03:53 +00:00
Kevin Stone
2f8d8b499e Patched DateField and DateTimeField to check for None values before trying to perform date(time) conversion.
Signed-off-by: Kevin Stone <kevinastone@gmail.com>
2013-03-06 15:16:37 -08:00
Tom Christie
1106596c80 Clean ups to datetime formatting 2013-03-06 12:19:39 +00:00
Tom Christie
c20ebe95f6 Merge datetime formats 2013-03-05 17:50:28 +00:00
Stephan Groß
5e5cd6f7f7 Fix for django 1.3 compatibility 2013-03-01 17:15:39 +01:00
Stephan Groß
12905449a5 Add format class attributes 2013-03-01 16:59:47 +01:00
Stephan Groß
9c964cf37b Add new ISO8601 setting + integration 2013-03-01 16:50:18 +01:00
Stephan Groß
a9d36d4726 Add docs update - part 1 2013-03-01 16:50:18 +01:00
Stephan Groß
f208d8d2bb Add drf settings + output format + testcases 2013-03-01 16:50:18 +01:00
Stephan Groß
b2165cc76a Fix for python 3 support - thanks @Linovia 2013-03-01 16:48:20 +01:00
Stephan Groß
9157db5da0 Add better date / datetime validation (pull 2)
addition to #631 with update to master + timefield support
2013-03-01 16:48:20 +01:00
Yuri Prezument
5f531fc1ea Catch TypeError as well as ValueError when parsing dates, ref #699 2013-02-21 15:54:31 +02:00
Tom Christie
367909e2c2 Merge pull request #657 from dgaus/master
Make is_simple_callable consider default arguments
2013-02-15 01:13:14 -08:00
Andreas Pelme
5a5df18d18 Added a serializer TimeField 2013-02-14 21:19:51 +01:00
Diego Gaustein
40b13a869b Make is_simple_callable consider fields which have default arguments 2013-02-13 20:34:23 -03:00
Tom Christie
f505b2e440 Clean up field_to_native logic 2013-02-12 22:59:01 +00:00
Tom Christie
670ac25b25 Allow serializers to handle dicts as well as objects. Fixes #447. 2013-02-07 12:57:40 +00:00
Marc Tamlyn
bd7977eed7 Purge naked excepts.
Most of these had obvious exceptions which would be thrown. Some I'm not
sure about but they should at least catch only Exception so as not to
ignore SystemExit and other inappropriate Error classes.
2013-02-06 13:05:17 +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
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
e4ac566625 Add dprecation warnings 2013-01-30 20:33:50 +00:00
Tom Christie
be6df3ae3c Merge branch 'master' into many-fields
Conflicts:
	rest_framework/relations.py
2013-01-30 13:41:56 +00:00
Tom Christie
9a4d01d687 Formatting fixes 2013-01-30 12:41:26 +00:00
Tom Christie
7ed81c3c66 Tweak comment. 2013-01-03 22:06:55 +00:00
Tom Christie
6da21fa796 Merge pull request #541 from yprez/default_and_partial_serializers2
Fix "default" values and partial serializers.  Fixes #532.
2013-01-03 14:05:36 -08:00
Xavier Ordoquy
60250f22c8 Move the various compat things to the compat module. 2013-01-03 11:41:07 +01:00
Yuri Prezument
3f5e938247 Some cleanup 2013-01-03 08:28:17 +02:00
Yuri Prezument
f2625fc38c FileField validation - handle case when files=None, fixes #542 2013-01-02 22:12:26 +02:00
Xavier Ordoquy
45d48dd52f urlparse not used here. 2013-01-02 18:54:55 +01:00
Xavier Ordoquy
737349d238 Merge remote-tracking branch 'reference/py3k' into p3k 2013-01-02 16:09:21 +01:00
Yuri Prezument
3873bc8a85 Add explaining comment 2013-01-02 15:57:00 +02:00
Yuri Prezument
6b962cfcf7 Fix "default" and partial serializers, fixes #532 2013-01-02 15:56:46 +02:00
Tom Christie
8fad0a727a Relation fields move into relations.py 2012-12-31 08:53:40 +00:00
Michal Dvorak
5d7d51ed9d Merge remote-tracking branch 'upstream/master' 2012-12-23 22:05:16 +01:00
Mark Aaron Shirley
f8a1256b1c Update RelatedField#field_from_native coding style 2012-12-21 11:33:01 -08:00