divio / aldryn-search

Haystack 2.0 search index for django CMS
Other
48 stars 77 forks source link

AttributeError: module 'django.db.models' has no attribute 'FieldDoesNotExist' #110

Open didierCH opened 3 years ago

didierCH commented 3 years ago

The following line of code will cause issues in Django 3.1 and later: https://github.com/divio/aldryn-search/blob/a62715a07d296c117304a055202da417723a6dea/aldryn_search/utils.py#L125

As in the Django 3.1 release notes is stated: "The compatibility import of django.core.exceptions.FieldDoesNotExist in django.db.models.fields is removed."

A possible fix for this is to import from django.core import exceptions and replace the following except (AttributeError, models.FieldDoesNotExist): with except (AttributeError, exceptions.FieldDoesNotExist):