diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index e9e3f4a..05f16db 100644
a
|
b
|
class Field(object):
|
404 | 404 | return first_choice + list(self.flatchoices) |
405 | 405 | |
406 | 406 | def _get_val_from_obj(self, obj): |
407 | | if obj: |
| 407 | if obj is not None: |
408 | 408 | return getattr(obj, self.attname) |
409 | 409 | else: |
410 | 410 | return self.get_default() |
diff --git a/tests/regressiontests/serializers_regress/models.py b/tests/regressiontests/serializers_regress/models.py
index ccd8503..087551e 100644
a
|
b
|
class InheritBaseModel(BaseModel):
|
258 | 258 | class ExplicitInheritBaseModel(BaseModel): |
259 | 259 | parent = models.OneToOneField(BaseModel) |
260 | 260 | child_data = models.IntegerField() |
| 261 | |
| 262 | class LengthModel(models.Model): |
| 263 | data = models.IntegerField() |
| 264 | |
| 265 | def __len__(self): |
| 266 | return self.data |
diff --git a/tests/regressiontests/serializers_regress/tests.py b/tests/regressiontests/serializers_regress/tests.py
index 11b53a5..84e90ff 100644
a
|
b
|
forward, backwards and self references.
|
8 | 8 | """ |
9 | 9 | |
10 | 10 | |
11 | | import unittest, datetime |
| 11 | import datetime |
| 12 | import decimal |
| 13 | import unittest |
12 | 14 | from cStringIO import StringIO |
13 | 15 | |
14 | 16 | from django.utils.functional import curry |
… |
… |
from django.core import management
|
18 | 20 | from django.conf import settings |
19 | 21 | |
20 | 22 | from models import * |
21 | | try: |
22 | | import decimal |
23 | | except ImportError: |
24 | | from django.utils import _decimal as decimal |
25 | 23 | |
26 | 24 | # A set of functions that can be used to recreate |
27 | 25 | # test data objects of various kinds. |
… |
… |
The end."""),
|
326 | 324 | (data_obj, 1001, BigIntegerData, -9223372036854775808), |
327 | 325 | (data_obj, 1002, BigIntegerData, 0), |
328 | 326 | (data_obj, 1003, BigIntegerData, None), |
| 327 | (data_obj, 1004, LengthModel, 0), |
| 328 | (data_obj, 1005, LengthModel, 1), |
329 | 329 | ] |
330 | 330 | |
331 | 331 | # Because Oracle treats the empty string as NULL, Oracle is expected to fail |