aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/fields.py
diff options
context:
space:
mode:
authorTom Christie2013-05-18 04:24:16 -0700
committerTom Christie2013-05-18 04:24:16 -0700
commit0c95405ea7d9d93c2f03add3ec8c10afad08b63a (patch)
tree845f6c301d3069b35a0587a843dc076c1b1e2226 /rest_framework/fields.py
parent2a3056d03844a31373f1e30aec58e70616115838 (diff)
parent8fe43236a22e56d1741b49b92f0c53e01cd9e5f6 (diff)
downloaddjango-rest-framework-0c95405ea7d9d93c2f03add3ec8c10afad08b63a.tar.bz2
Merge pull request #853 from pyriku/725-blank-choice-dash
Adds BLANK_CHOICE_DASH as a choice item
Diffstat (limited to 'rest_framework/fields.py')
-rw-r--r--rest_framework/fields.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py
index 49d2a6d5..9bbe6633 100644
--- a/rest_framework/fields.py
+++ b/rest_framework/fields.py
@@ -15,6 +15,7 @@ import warnings
from django.core import validators
from django.core.exceptions import ValidationError
from django.conf import settings
+from django.db.models.fields import BLANK_CHOICE_DASH
from django import forms
from django.forms import widgets
from django.utils.encoding import is_protected_type
@@ -407,6 +408,8 @@ class ChoiceField(WritableField):
def __init__(self, choices=(), *args, **kwargs):
super(ChoiceField, self).__init__(*args, **kwargs)
self.choices = choices
+ if not self.required:
+ self.choices = BLANK_CHOICE_DASH + self.choices
def _get_choices(self):
return self._choices