summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ishtar_common/models.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index f2ebb3c29..ef9a59937 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -54,7 +54,8 @@ from django.contrib.postgres.fields import JSONField
from django.contrib.postgres.search import SearchVectorField, SearchVector
from django.contrib.sites.models import Site
from django.core.cache import cache
-from django.core.exceptions import ObjectDoesNotExist, ValidationError
+from django.core.exceptions import ObjectDoesNotExist, ValidationError, \
+ MultipleObjectsReturned
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.files import File
from django.core.serializers import serialize
@@ -63,7 +64,6 @@ from django.core.validators import validate_slug
from django.db import connection
from django.db.models import Q, Max, Count, F
from django.db.models.signals import post_save, post_delete, m2m_changed
-from django.db.models.fields.related import ManyToManyField, ManyToManyRel
from django.db.utils import DatabaseError
from django.template.defaultfilters import slugify
from django.utils.functional import lazy
@@ -153,14 +153,16 @@ class ValueGetter(object):
if hasattr(self, "qrcode"):
values['qrcode_path'] = self.qrcode_path
for field_name in get_all_field_names(self):
- if not hasattr(self, field_name) or \
- field_name in self.GET_VALUES_EXCLUDE_FIELDS:
+ try:
+ value = getattr(self, field_name)
+ except (AttributeError, MultipleObjectsReturned):
+ continue
+ if field_name in self.GET_VALUES_EXCLUDE_FIELDS:
continue
if hasattr(self, "get_values_for_" + field_name):
values[prefix + field_name] = getattr(
self, "get_values_for_" + field_name)()
else:
- value = getattr(self, field_name)
if hasattr(value, 'get_values'):
values.update(value.get_values(prefix + field_name + '_'))
else: