- 16 Jan, 2013 4 commits
-
-
Tom Christie committed
-
See: #585
Tom Christie committed -
Tom Christie committed
-
https://github.com/steve-gregory/django-rest-framework…
Merge branch 'master' of https://github.com/steve-gregory/django-rest-framework into slug-field-fixes
Tom Christie committed
-
- 15 Jan, 2013 10 commits
-
-
Steven Gregory committed
-
See: #584
Tom Christie committed -
Tom Christie committed
-
Adding timedelta support to JSONEncoder, and an example of how to add decode support to a serializer.
Tom Christie committed -
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()
James Cleveland committed -
Stephan Groß committed
-
Fixed a minor template bug
Stephan Groß committed -
Johannes Spielmann committed
-
Tom Christie committed
-
Tom Christie committed
-
- 14 Jan, 2013 3 commits
-
-
Tom Christie committed
-
Tom Christie committed
-
Tom Christie committed
-
- 13 Jan, 2013 2 commits
-
-
Format extensions have already been introduced.
Tom Christie committed -
If format extensions are used, they must be used in the creation of the reverse URLs.
Richard Wackerbarth committed
-
- 12 Jan, 2013 7 commits
-
-
A minor gramatical correction
Stephan Groß committed -
Richard Wackerbarth committed
-
Stephan Groß committed
-
Stephan Groß committed
-
Tom Christie committed
-
Tom Christie committed
-
Tom Christie committed
-
- 11 Jan, 2013 3 commits
-
-
Stephan Groß committed
-
Tom Christie committed
-
Make the whitespace uniform
Tom Christie committed
-
- 10 Jan, 2013 7 commits
-
-
Richard Wackerbarth committed
-
Revised Tutorial
Tom Christie committed -
Richard Wackerbarth committed
-
Richard Wackerbarth committed
-
This is to allow the addition of elements without having to change existing lines of code
Richard Wackerbarth committed -
Unused imports
Tom Christie committed -
Juan Riaza committed
-
- 09 Jan, 2013 1 commit
-
-
Tom Christie committed
-
- 08 Jan, 2013 3 commits
-
-
Handle ObjectDoesNotExist exceptions when serializing null reverse one-to-one
Mark Shirley committed -
Mark Aaron Shirley committed
-
Mark Aaron Shirley committed
-