From 5a9aa344151a589436d643bfcfc563f09c9a7270 Mon Sep 17 00:00:00 2001 From: Ludwig Kraatz Date: Tue, 4 Dec 2012 13:40:07 +0100 Subject: [PATCH] compat for django 1.3x fixed empty was introduced Django > 1.3 --- rest_framework/compat.py | 7 +++++++ rest_framework/serializers.py | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 09b763681..b09487f38 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -343,6 +343,13 @@ except ImportError: kw = dict((k, int(v)) for k, v in kw.iteritems() if v is not None) return datetime.datetime(**kw) + +# empty does not exist in 1.3x +if django.VERSION >= (1, 4): + from django.utils.functional import empty +else: + empty = object() + # Markdown is optional try: import markdown diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 80437952f..80eefbf08 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -5,9 +5,8 @@ from decimal import Decimal from django.db import models from django.forms import widgets from django.utils.datastructures import SortedDict -from django.utils.functional import empty from django.core.exceptions import ImproperlyConfigured -from rest_framework.compat import get_concrete_model +from rest_framework.compat import get_concrete_model, empty # Note: We do the following so that users of the framework can use this style: #