mirror of
https://github.com/Hopiu/django-watson.git
synced 2026-03-16 22:00:22 +00:00
checks if the field passed on is a related manager
This commit is contained in:
parent
b3d677db2b
commit
765367913a
1 changed files with 6 additions and 4 deletions
|
|
@ -52,12 +52,14 @@ class SearchAdapter(object):
|
|||
# Get the attribute.
|
||||
if hasattr(obj, prefix):
|
||||
value = getattr(obj, prefix)
|
||||
if callable(value):
|
||||
value = value()
|
||||
if not isinstance(value, (QuerySet, models.Manager)):
|
||||
if callable(value):
|
||||
value = value()
|
||||
elif hasattr(self, prefix):
|
||||
value = getattr(self, prefix)
|
||||
if callable(value):
|
||||
value = value(obj)
|
||||
if not isinstance(value, (QuerySet, models.Manager)):
|
||||
if callable(value):
|
||||
value = value(obj)
|
||||
else:
|
||||
raise SearchAdapterError("Could not find a property called {name!r} on either {obj!r} or {search_adapter!r}".format(
|
||||
name = prefix,
|
||||
|
|
|
|||
Loading…
Reference in a new issue