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
Tom Christie
296b737fb6
Fix repeated breadcrumbs when optional trailing slash is used
2012-11-07 10:03:51 +00:00
Tom Christie
9c1fba3483
Tweak parsers to take parser_context
2012-10-15 13:27:50 +01:00
Tom Christie
d905d1cbd3
Fix yaml rendering
2012-10-10 16:34:00 +01:00
Tom Christie
4b691c4027
Change package name: djangorestframework -> rest_framework
2012-09-20 13:06:27 +01:00