Skip to content

Commit 68794f9

Browse files
Merge pull request #247 from barseghyanartur/fix/242-basedocumentviewset-get-object-does-not-provide-access-to-meta-id
242 Fixes
2 parents ac07e39 + b0c0b82 commit 68794f9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/django_elasticsearch_dsl_drf/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ def __init__(self, mapping, meta=None):
5959
self.meta = meta
6060

6161
def __getattr__(self, item):
62+
if item == "meta":
63+
return self.meta
6264
val = self.__mapping.get(item, None)
6365
if isinstance(val, datetime.datetime) and not val.tzinfo:
6466
val = val.date()

src/django_elasticsearch_dsl_drf/viewsets.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,17 @@ def get_object(self):
240240

241241
# May raise a permission denied
242242
self.check_object_permissions(self.request, obj)
243+
243244
if ELASTICSEARCH_GTE_7_0:
244245
dictionary_proxy = self.dictionary_proxy(
245246
obj.to_dict(),
246-
obj.meta
247+
getattr(obj, 'meta', None)
247248
)
248249
else:
249-
dictionary_proxy = self.dictionary_proxy(obj, obj.meta)
250+
dictionary_proxy = self.dictionary_proxy(
251+
obj,
252+
getattr(obj, 'meta', None)
253+
)
250254

251255
return dictionary_proxy
252256

0 commit comments

Comments
 (0)