Permalink
Browse files

See #47 Now it is more robust

  • Loading branch information...
1 parent 0c26a57 commit 089507f1069d79d35cff7fee123b6166047e23fe @goinnn goinnn committed Dec 28, 2013
@@ -14,6 +14,7 @@
# along with this programe. If not, see <http://www.gnu.org/licenses/>.
import json
+import numbers
import sys
from copy import deepcopy
@@ -465,9 +466,9 @@ class BaseNumberField(BaseAdaptorField):
def render_value(self, field_name=None):
value = super(BaseNumberField, self).render_value(field_name=field_name)
- if isinstance(value, string):
- return value
- return number_format(value)
+ if isinstance(value, numbers.Number):
+ value = number_format(value)
+ return value
class AdaptorIntegerField(BaseNumberField):
@@ -3,7 +3,7 @@
"pk": 1,
"model": "unusual_fields.unusualmodel",
"fields": {
- "float_field": 4.0,
+ "float_field": null,
"url_field": "http://www.yaco.es/",
"email_field": "pmartin@yaco.es",
"time_field": "13:37:42",
@@ -29,7 +29,7 @@ class UnusualModel(models.Model):
decimal_field = models.DecimalField(decimal_places=10, max_digits=20)
filepath_field = models.FilePathField(path=os.path.join(settings.MEDIA_ROOT, 'images'),
null=True, blank=True)
- float_field = models.FloatField()
+ float_field = models.FloatField(null=True, blank=True)
if django.VERSION[0] >= 1 and django.VERSION[0] >= 4:
generic_ip_field = models.GenericIPAddressField()
else:

0 comments on commit 089507f

Please sign in to comment.