aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/utils
AgeCommit message (Collapse)Author
2013-04-26Deal with List/Instance suffixes for viewsetsTom Christie
2013-04-04Factor view names/descriptions out of View classTom Christie
2013-02-22XML cleanupTom Christie
2013-02-04Cleanup importsTom Christie
Mostly adding `from __future__ import unicode_literals` everywhere.
2013-02-01Py3k cleanupTom Christie
2013-02-01Merge branch 'p3k' of https://github.com/linovia/django-rest-framework into ↵Tom Christie
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-01-15Add timedelta encoder to the JSONEncoder class.James Cleveland
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-05deprecate simplejsonJuan Riaza
2013-01-03Move the various compat things to the compat module.Xavier Ordoquy
2012-11-24Every (base) test should now pass with python3.Xavier Ordoquy
2012-11-23Default encoding should probably be latin-1 as some RFC seems to imply it.Xavier Ordoquy
2012-11-226 first tests passes under python 3.2Xavier Ordoquy
2012-11-22First passing test under p3k \o/Xavier Ordoquy
2012-11-07Make filtering optional, and pluggable.Tom Christie
2012-11-07Fix repeated breadcrumbs when optional trailing slash is usedTom Christie
2012-10-15Tweak parsers to take parser_contextTom Christie
2012-10-10Fix yaml renderingTom Christie
2012-09-20Change package name: djangorestframework -> rest_frameworkTom Christie