Django error : object has no attribute 'resolve_expression'

Viewed 179

Can you give me a hint where to look or what to look for?

Using Python 3.7.9 and Django 3.1.8, I have the following exception when in DEBUG mode. The problem does not appear when running in normal mode.

The problem is new, it was first seen this week (it might have been there before). Going back in git does not help, the problem is still there. There is a lot of code changed.

Can you please give me a hint or a solution? Django is new for me and I do not know how to tackle the issue.

Exception has occurred: AttributeError       (note: full exception trace is shown but execution is paused at: __getattribute__)
'Organization' object has no attribute 'resolve_expression'
  File "****/legal_entity/submodels/organization.py", line 416, in __getattribute__ (Current frame)
    return super().__getattribute__(name)
  File "****/.local/share/virtualenvs/****-zDD7ik9_/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1062, in resolve_lookup_value
    if hasattr(value, 'resolve_expression'):
  File "****/.local/share/virtualenvs/****-zDD7ik9_/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1267, in build_filter
    value = self.resolve_lookup_value(value, can_reuse, allow_joins)
  File "****/.local/share/virtualenvs/****-zDD7ik9_/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1380, in _add_q
    split_subq=split_subq, check_filterable=check_filterable,
  File "****/.local/share/virtualenvs/****-zDD7ik9_/lib/python3.7/site-packages/django/db/models/sql/query.py", line 1358, in add_q
    clause, _ = self._add_q(q_object, self.used_aliases)
  File "****/.local/share/virtualenvs/****-zDD7ik9_/lib/python3.7/site-packages/django/db/models/query.py", line 969, in _filter_or_exclude_inplace
    self._query.add_q(Q(*args, **kwargs))
  File "****/.local/share/virtualenvs/****-zDD7ik9_/lib/python3.7/site-packages/django/db/models/query.py", line 962, in _filter_or_exclude
    clone._filter_or_exclude_inplace(negate, *args, **kwargs)
  File "****/.local/share/virtualenvs/****-zDD7ik9_/lib/python3.7/site-packages/django/db/models/query.py", line 942, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File "****/core/subserializers/abstract/business_object.py", line 52, in get_authorized_activities
    user=instance.request_user
.................
1 Answers

An AttributeError is an error that is raised when an attribute reference fails.

So the object Organization has no attribute or variable resolve expression. It might be that your method of reference is wrong because the attribute is there but django can't see it.

So I advice you show the affected code

Related