Stian Jensen
62c000bc12
Use model error_messages when available
...
In the automatically applied UniqueValidator, use the error message from
error_messages defined in the model instead of the generic default
UniqueValidator message.
This fixes #2878 .
2015-09-23 15:20:44 +02:00
Carlton Gibson
45ace5010e
Remove OrderedDict fallback
2015-09-22 16:35:38 +02:00
Carlton Gibson
6e86a53c92
Remove apps.get_model
fallback
...
* Corrects presumed logic error in `ResolveModelWithPatchedDjangoTests`
2015-09-22 16:14:45 +02:00
Carlton Gibson
8ea1606abf
Remove Django 1.5 clean_manytomany_helptext fallback
2015-09-21 20:16:52 +02:00
Tom Christie
a3067bea55
Merge branch 'master' into version-3.3
2015-09-17 16:24:46 +01:00
Tom Christie
f9d1a34fdd
Fix nested HTML dictionaries. Closes #3314 .
2015-09-03 11:23:58 +01:00
Tom Christie
afd2a8f8f0
Adjust ModelField.null mappings now that Django-25320 is resolved
2015-09-03 10:12:52 +01:00
Tom Christie
78632849cf
Comment against model_field.null 1.98 behavior
2015-08-28 13:29:57 +01:00
Tom Christie
8db6367188
Deal with 1.9's differing null behavior on reverse relationships and m2m
2015-08-28 12:08:32 +01:00
Tom Christie
4f27697467
Fix get_model import
2015-08-27 17:28:12 +01:00
Tom Christie
b6c4d8c25a
Resolve duplicate error for IPAddressField. Closes #3250 .
2015-08-20 12:38:48 +01:00
Ollie Walsh
332c30afb9
Lint
2015-08-14 12:20:25 +01:00
Ollie Walsh
3d0292e1cd
Do not ignore overridden View.get_view_name() in breadcrumbs
2015-08-14 12:16:57 +01:00
Jeffrey de Lange
f5a9904cc8
Resolved issue with rendering of nested serializers form when value is None
2015-08-11 20:27:41 +02:00
Tom Christie
a3e64fbe0d
Resolve issue with rendering nested serializer forms with empty values. Closes #3260 .
2015-08-11 16:25:02 +01:00
Tom Christie
83e49dbe63
Fix checkbox input display. Refs #3258 .
2015-08-11 09:23:49 +01:00
Tymur Maryokhin
4e5da16961
Remove Django 1.4 compat code
2015-08-07 00:02:29 +02:00
Tom Christie
27ac5a3680
Support grouped choices
2015-08-06 11:43:03 +01:00
Tom Christie
6161ac7d07
Fix parse_html_dict signature. Closes #3212 .
2015-08-05 13:45:56 +01:00
Tom Christie
650866cc43
Blank relational fields map to required=False serializer fields. Closes #3210 .
2015-08-03 09:48:03 +01:00
Tom Christie
e68d737825
Respect blank on many to many, and set allow_empty=False if it is not present. Closes #2804 .
2015-07-30 17:03:08 +01:00
Tom Christie
b996266431
Merge master
2015-07-23 15:28:29 +01:00
Tom Christie
92008d3d16
None -> '' in the context of form field values
2015-07-23 14:36:23 +01:00
Tom Christie
a8acdbc388
Resolve issue with nested serializers in HTML forms. Closes #3153 .
2015-07-16 12:04:38 +01:00
Tom Christie
7315ed8b00
Resolve browsable API form issues with nested serializers. Closes #3153 .
2015-07-16 10:49:00 +01:00
Tom Christie
6b08e97b6a
Form fields should use textual only value representations. Closes #3139 . Closes #2416 . Closes #2558 .
2015-07-14 15:47:13 +01:00
José Padilla
7351a3f6ca
Sort imports with isort
2015-06-25 16:55:51 -04:00
José Padilla
83c9136c90
Cleanup import following PEP 8 style guide
2015-06-25 16:10:17 -04:00
Tom Christie
8d4c96ecd6
Merge pull request #3012 from jannon/fix-allow-blank-mapping
...
only include 'allow_blank' on supported fields
2015-06-24 11:01:10 +01:00
Tom Christie
e3b578258a
Merge pull request #2769 from nonZero/patch-1
...
Wrong error message on bad field lookup
2015-06-22 17:04:04 +01:00
Jannon Frank
2c415d7e03
models.TextFields get mapped to serializers.CharField too
2015-06-16 14:05:19 -07:00
Jannon Frank
b0752217ae
only include 'allow_blank' on CharField
2015-06-05 02:21:13 -07:00
Tom Christie
ec8e7f27e7
Fixes for format preservation
2015-05-19 15:49:37 +01:00
Udi Oron
b95ef25cbb
Wrong error message on bad field lookup
2015-03-26 20:13:35 +02:00
Ilias Kiourktsidis
0888f9cfc3
Use _meta instead of Meta on is_abstract_model function
2015-03-25 12:00:20 +00:00
Ilias Kiourktsidis
486f0a9367
Raise error when ModelSerializer used with abstract model
2015-03-23 15:01:19 +00:00
Tom Christie
dbd2352165
Fixes for latest pep8 updates. Refs #2563 .
2015-02-17 10:58:00 +00:00
Tom Christie
4ee4b4f2dc
Merge master
2015-01-30 14:00:25 +00:00
Tom Christie
889a07f556
Support assignment in ClassLookupDict
2015-01-23 15:32:21 +00:00
Tom Christie
39f26c9eca
Merge master
2015-01-23 14:28:59 +00:00
Tom Christie
25a703b42c
Work around meta API differences
2015-01-23 11:15:11 +00:00
Tom Christie
e59b3d1718
Make ReturnDict cachable. Closes #2360 .
2015-01-21 14:18:13 +00:00
Tom Christie
9ec08ce578
Merge master
2015-01-21 13:12:14 +00:00
Tom Christie
da6ef3d0b0
Allow missing fields option for inherited serializers. Closes #2388 .
2015-01-21 13:03:37 +00:00
Tom Christie
6065cdbd93
Merge master
2015-01-19 15:16:57 +00:00
Tom Christie
0dffc46cb7
ReturnDict and ReturnList repr as standard dict/list. Closes #2421 .
2015-01-19 14:21:09 +00:00
Tom Christie
da1db34a36
Handle UUID objects in JSONEncoder. Closes #2433 .
2015-01-19 14:19:01 +00:00
Fabien Bochu
5484d570cb
Fix timedelta JSON serialization on Python 2.6.
2015-01-19 13:09:08 +01:00
Tom Christie
86d2774cf3
Fix compat issues
2015-01-16 20:30:46 +00:00
Tom Christie
f13fcba9a9
Include paragraph around view description in browable API
2015-01-14 13:20:02 +00:00
Tom Christie
4d287c7aef
Include paragraph around view description in browable API
2015-01-14 13:19:56 +00:00
Tom Christie
6168f60ba8
Merge branch 'master' into version-3.1
2015-01-05 11:02:28 +00:00
Tom Christie
8cf3744971
Ensure no invalid min_length/min_value/max_value arguments. Closes #2369 .
2015-01-05 10:52:18 +00:00
Kyle Valade
a7479721c8
First pass at refactoring get_field_info in utils.model_meta
2014-12-29 00:35:00 -08:00
Tom Christie
ef2eff2aba
Only pass max_length for CharField. Closes #2317 .
2014-12-28 11:07:38 +00:00
Remi Paulmier
6c5ff71278
fix the way to use textarea rather than input with models.TextField
2014-12-22 18:05:07 +01:00
Tom Christie
2a1485e009
Final bits of docs for ModelSerializer fields API
2014-12-19 21:32:43 +00:00
Tom Christie
a68d9331fc
YAML encoder fix for 3.0 serializers.
2014-12-18 12:17:46 +00:00
Tom Christie
b6ee784240
Merge master
2014-12-15 12:18:55 +00:00
Tom Christie
dc66cce16d
Remove erronous print
2014-12-15 12:01:29 +00:00
Tom Christie
72e08a3e8b
Use unicode internally everywhere for 'repr'
2014-12-15 11:55:17 +00:00
Tom Christie
8934e61b67
Merge branch 'jpadilla-exception-handler-context' into version-3.1
2014-12-15 09:20:27 +00:00
Tom Christie
5e7c9687c7
First pass at serializer repr bug
2014-12-15 09:13:02 +00:00
Tom Christie
baaa356489
Merge master
2014-12-12 15:37:43 +00:00
Tom Christie
7d70e56ce3
Copy model field validators, don't reuse the same list.
2014-12-09 16:25:10 +00:00
José Padilla
afe7ed9333
Add allow_blank for ChoiceField #2184
...
This makes a ChoiceField optional in HTML if
model field has `blank=True` set.
2014-12-09 09:25:06 -04:00
Tymur Maryokhin
d54c67d79d
Removed custom StringIO, force_text, smart_text compat
2014-12-04 03:11:42 +01:00
Tymur Maryokhin
09e59f2686
Removed custom python_2_unicode_compatible. Closes #2183
2014-12-04 02:50:25 +01:00
Tom Christie
33096a1de6
BindingDict inherits from collections.MutableMapping. Closes #2135 .
2014-12-02 15:15:21 +00:00
José Padilla
731c8421af
Remove YAML support from core
2014-11-29 14:43:05 -04:00
Tom Christie
3a5b3772fe
Use ImproperlyConfigured when model meta lookup fails
2014-11-28 15:36:04 +00:00
Doug Beck
67735687b2
Ensure _resolve_model
does not return None
2014-11-18 01:26:23 -05:00
Tom Christie
4e03518438
required=False for nullable relationships
2014-11-13 23:30:42 +00:00
Tom Christie
cb672a0ecb
Merge branch 'master' of https://github.com/tomchristie/django-rest-framework
2014-11-13 22:16:53 +00:00
Tom Christie
ea98de9b88
Model fields with .blank or .null now map to required=False. Closes #2017 . Closes #2021 .
2014-11-13 19:28:57 +00:00
Tom Christie
e70b82b6c8
Update html.py
2014-11-12 15:38:39 +00:00
Tom Christie
1838e18aee
Update html.py
2014-11-12 15:38:05 +00:00
Tom Christie
a16a8a10a9
.copy() for serializer .data and .errors dictionaries
2014-11-07 11:16:26 +00:00
Tom Christie
e399140031
Minor tweaks
2014-11-07 10:51:08 +00:00
Tom Christie
9b19b5a594
Serializer cleanup
2014-11-07 10:13:46 +00:00
Tom Christie
db1dd8e240
Tests & fixes for list serialization
2014-11-06 17:32:33 +00:00
Tom Christie
4e001dbb7a
Drop usage of SortedDict. Closes #2027 .
2014-11-06 12:00:30 +00:00
Tom Christie
207208fedf
Lazy loading of fields and validators. Closes #1963 .
2014-10-31 16:38:39 +00:00
Tom Christie
87fdc73f64
Merge pull request #1920 from thedrow/topic/encoder-improvements
...
The JSON encoder now uses tuples instead of lists
2014-10-09 08:31:46 +01:00
Tom Christie
14ae52a24e
More gradual deprecation
2014-10-08 16:09:37 +01:00
Tom Christie
6bfed6f852
Enforce uniqueness validation for relational fields
2014-10-07 17:04:53 +01:00
Tom Christie
df7b6fcf58
First pass on incorperating the form rendering into the browsable API
2014-10-02 16:24:24 +01:00
Omer Katz
79e91dff92
The encoder now returns tuples instead of lists.
...
Tuples take a little less memory which is significant when serializing a lot of objects.
2014-10-02 16:44:20 +03:00
Tom Christie
c171fa21ac
First pass at HTML form rendering
2014-10-01 19:44:46 +01:00
Tom Christie
c630a12e26
Deal with lazy strings in serializer reprs
2014-10-01 13:24:47 +01:00
Tom Christie
381771731f
Use six.text_type instead of str everywhere
2014-10-01 13:09:14 +01:00
Tom Christie
43fd5a8730
Uniqueness validation
2014-09-29 09:24:03 +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
9fdb2280d1
First pass on ManyRelation
2014-09-18 14:23:00 +01:00
Tom Christie
5b7e4af0d6
get_base_field() refactor
2014-09-18 11:20:56 +01:00
Tom Christie
40dc588a37
Drop label from serializer fields when not needed
2014-09-15 09:50:51 +01:00
Tom Christie
22af49bf8f
Tidy up JSONEncoder
2014-09-12 11:50:20 +01:00
Tom Christie
adcb64ab41
MethodField -> SerializerMethodField
2014-09-12 09:12:56 +01:00
Tom Christie
040bfcc09c
NotImplemented stubs for Field, and DecimalField improvements
2014-09-11 21:48:54 +01:00
Tom Christie
bf52d04f4c
Nice manager representations on serializer classes
2014-09-11 20:37:27 +01:00
Tom Christie
3318f75a71
Improve memory address removal for serializer representations
2014-09-11 13:50:53 +01:00
Tom Christie
54ccf7230d
Improve memory address removal for serializer representations
2014-09-11 13:43:46 +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
b1c07670ca
Fleshing out serializer fields
2014-09-09 17:46:28 +01:00
José Padilla
c9d4497d81
Use force_text from compat
2014-09-05 15:58:53 -07:00
José Padilla
d44a8f24ff
Merge remote-tracking branch 'poswald/view-description-as-promise' into view-description-as-promise
2014-09-05 15:34:16 -07: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
2d2737f367
Resolve python3 linting issue
2014-08-19 14:11:26 +01:00
Tom Christie
bf09c32de8
Code linting and added runtests.py
2014-08-19 13:28:07 +01:00
Paul Oswald
3e93c96ece
replace unicode call with force_text
2014-08-19 10:09:48 +09:00
Paul Oswald
66fa40c300
evaluate content at function start
2014-07-29 22:13:11 +09:00
Paul Oswald
921e4ed2ee
Evaluate content before passing to regex.sub
...
Issue #1708
2014-07-28 16:59:55 +09: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 Leith
613df5c650
Fix dict_keys equality test for python 3.
2014-04-11 05:49:49 +01:00
Mathieu Pillard
f034cb595a
Encode django QuerySets to lists and not dicts in JSONEncoder
2014-01-17 13:05:10 +01: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
ddd17c69e7
Fix compat issues for #1231
2013-12-09 09:24:10 +00:00
Malcolm Box
263281d71d
Fix issue #1231 : JSONEncoder doesn't handle dict-like objects
...
Check for __getitem__ and then attempt to convert to a dict.
The check for __getitem__ is there as there's no universal way to
check if an object is a mapping type, but this is a likely proxy
2013-11-21 20:09:48 +00:00
badaud_t
b730aec0f4
Fix decimal support with YAMLRenderer
2013-10-17 01:08:24 +02:00
Tom Christie
e441f85109
Drop 1.3 support
2013-09-25 10:30:04 +01:00
David Pretty
d489c5c881
Let JSONEncoder handle Numpy data types.
...
json.JSONEncoder cannot serialize Numpy data types. Numpy arrays
and array scalars have a tolist() method which casts the object to
a standard python data type.
2013-09-13 13:36:18 +10:00
Tom Christie
02b6836ee8
Fix breadcrumb view names
2013-08-29 20:51:51 +01:00
Tom Christie
89b0a539c3
Move view name/description functions into public space
2013-08-19 08:24:27 +01:00
Christopher Paolini
11d7c1838a
Updated default view name/description functions
...
Forgot to update the default view name/description functions to the new
setup.
2013-08-17 17:52:08 -04:00
Christopher Paolini
e6662d434f
Improved view/description function setting
...
Now supports each View having its own name and description function and
overriding the global default.
2013-08-17 17:44:51 -04:00
Christopher Paolini
a95984e4d4
Settings now have default functions
...
Updated the setting to have a default function.
2013-08-16 13:23:04 -04:00
Christopher Paolini
d07dae6e79
Ability to override name/description of view
...
Added settings and additions to formatting.py
2013-08-15 12:41:52 -04:00
Igor Kalat
c8b0e6c40f
Refactored get_view_description, moved appropriate tests to test_description.py
2013-06-26 22:12:02 +02:00
Igor Kalat
2bf5f63050
Make browsable API views play nice with utf-8
2013-06-22 19:21:28 +02:00
Tom Christie
fcaee6e580
Clean up OPTIONS implementation
2013-05-24 23:44:23 +01:00
Tom Christie
d7c08222f1
Fix breadcrumb rendering issue
2013-05-07 14:11:48 +01:00
Tom Christie
018d8b8dce
Bits of cleanup
2013-04-26 15:11:11 +01:00
Tom Christie
8fa79a7fd3
Deal with List/Instance suffixes for viewsets
2013-04-26 14:59:21 +01:00
Tom Christie
f68721ade8
Factor view names/descriptions out of View class
2013-04-04 21:42:26 +01:00
Tom Christie
a39de47cc7
XML cleanup
2013-02-22 19:46: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
00752dcd2a
Py3k cleanup
2013-02-01 15:07:51 +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
James Cleveland
4fc3b1ba56
Add timedelta encoder to the JSONEncoder class.
...
Whilst this commit adds *encoding* of timedeltas to a string of a floating
point value of the seconds, you must add your own serializer field for
whatever timedelta model field you are using. This is because Django doesn't
support any kind of timedelta field out-of-the-box, so you have to either
implement your own or use django-timedelta.
If this is the case and you want to serialise timedelta input, you will have
to implement your own special field to use for the timedelta, which is not
included in core as it is based on a 3rd party library. Here is an example:
import datetime
import timedelta
from django import forms
from django.core import validators
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from rest_framework.fields import WritableField
class TimedeltaField(WritableField):
type_name = 'TimedeltaField'
form_field_class = forms.FloatField
default_error_messages = {
'invalid': _("'%s' value must be in seconds."),
}
def from_native(self, value):
if value in validators.EMPTY_VALUES:
return None
try:
return datetime.timedelta(seconds=float(value))
except (TypeError, ValueError):
msg = self.error_messages['invalid'] % value
raise ValidationError(msg)
Which is based on the FloatField. This field can then be used in
your serializer like this:
from yourapp.fields import TimedeltaField
class YourSerializer(serializers.ModelSerializer):
duration = TimedeltaField()
2013-01-15 13:08:52 +00:00
Juan Riaza
a061e3d9e2
deprecate simplejson
2013-01-05 13:40:02 +01:00
Xavier Ordoquy
60250f22c8
Move the various compat things to the compat module.
2013-01-03 11:41:07 +01:00
Xavier Ordoquy
17000129e3
Every (base) test should now pass with python3.
2012-11-24 23:19:03 +01:00
Xavier Ordoquy
b68263fb65
Default encoding should probably be latin-1 as some RFC seems to imply it.
2012-11-23 01:11:09 +01:00
Xavier Ordoquy
606c20f012
6 first tests passes under python 3.2
2012-11-22 02:08:00 +01:00
Xavier Ordoquy
b3698acb6c
First passing test under p3k \o/
2012-11-22 00:20:49 +01:00
Tom Christie
47b534a13e
Make filtering optional, and pluggable.
2012-11-07 21:07:24 +00:00