liberation / django-elasticsearch

Simple wrapper around elasticsearch-py to index/search a django Model.
MIT License
212 stars 73 forks source link

Serializer doesn't work in django 2 #78

Open M1ha-Shvn opened 5 years ago

M1ha-Shvn commented 5 years ago

Hi. rel attribute is deprecated in django 2.0. So serializer is broken. Most probably rel should be replaced with remote_field attribute for Django 2.0 support.

  File "/home/vagrant/venv/lib/python3.7/site-packages/django_elasticsearch/managers.py", line 46, in wrapper
    return f(*args, **kwargs)
  File "/home/vagrant/venv/lib/python3.7/site-packages/django_elasticsearch/managers.py", line 104, in serialize
    return serializer.serialize(self.instance)
  File "/home/vagrant/venv/lib/python3.7/site-packages/django_elasticsearch/serializers.py", line 167, in serialize
    return json.dumps(self.format(instance),
  File "/home/vagrant/venv/lib/python3.7/site-packages/django_elasticsearch/serializers.py", line 154, in format
    for field in fields])
  File "/home/vagrant/venv/lib/python3.7/site-packages/django_elasticsearch/serializers.py", line 154, in <listcomp>
    for field in fields])
  File "/home/vagrant/venv/lib/python3.7/site-packages/django_elasticsearch/serializers.py", line 118, in serialize_field
    if field.rel:
AttributeError: 'IntegerField' object has no attribute 'rel'