X-Git-Url: http://git.ithinksw.org/philo.git/blobdiff_plain/b4cd9f878117f7398442acb09d40b520f321a91d..1fb4774474207933a6cce19e65a2fa011593b3eb:/philo/models/fields/entities.py?ds=sidebyside diff --git a/philo/models/fields/entities.py b/philo/models/fields/entities.py index cc8c398..167fd39 100644 --- a/philo/models/fields/entities.py +++ b/philo/models/fields/entities.py @@ -2,7 +2,7 @@ import datetime from itertools import tee from django import forms -from django.core.exceptions import FieldError +from django.core.exceptions import FieldError, ValidationError from django.db import models from django.db.models.fields import NOT_PROVIDED from django.utils.text import capfirst @@ -193,7 +193,10 @@ class JSONAttribute(AttributeProxyField): """If the field template is a :class:`DateField` or a :class:`DateTimeField`, this will convert the default return value to a datetime instance.""" value = super(JSONAttribute, self).value_from_object(obj) if isinstance(self.field_template, (models.DateField, models.DateTimeField)): - value = self.field_template.to_python(value) + try: + value = self.field_template.to_python(value) + except ValidationError: + value = None return value def get_storage_value(self, value): @@ -209,7 +212,7 @@ class ForeignKeyAttribute(AttributeProxyField): """ Handles an :class:`.Attribute` with a :class:`.ForeignKeyValue`. - :param limit_choices_to: A :class:`Q` object, dictionary, or :class:`.ContentTypeLimiter` to restrict the queryset for the :class:`ForeignKeyAttribute`. + :param limit_choices_to: A :class:`Q` object, dictionary, or :class:`ContentTypeLimiter ` to restrict the queryset for the :class:`ForeignKeyAttribute`. """ value_class = ForeignKeyValue