django-elasticsearch-dsl-drf icon indicating copy to clipboard operation
django-elasticsearch-dsl-drf copied to clipboard

Bug in ``_get_default_field_kwargs``

Open bors-ltd opened this issue 6 years ago • 3 comments

Hi,

I think I found a bug on this line: https://github.com/barseghyanartur/django-elasticsearch-dsl-drf/blob/c9556609a07cec90ceaac25ba0c91f2edee74b1b/src/django_elasticsearch_dsl_drf/serializers.py#L170

Options.get_fields returns a list of field instances, not names. This will never match.

I found this out when searching why my blank fields were not automatically marked as not required by the serializer's dynamic mapping.

bors-ltd avatar Feb 07 '19 17:02 bors-ltd

@bors-ltd:

Thanks for reporting this. I've checked the code. That part needs refactoring. I'll either fix it or remove unnecessary code parts.

Regarding the fields being marked as not required by the serializer's dynamic mapping - we deal with read-only viewsets. Data is only retrieved and is not written back to Elastic through DRF.

barseghyanartur avatar Feb 07 '19 19:02 barseghyanartur

Then I have another problem because null values are not part of the response hits and the serializer will choke on this.

For now I manually set those fields in the serializer.

bors-ltd avatar Feb 08 '19 08:02 bors-ltd

@bors-ltd:

I think you might have misconfigured something or didn't follow the docs/examples thoroughly.

My first suggestion would be - clone the project and run the example app - see if what you get there is what you expect to see, the way you expect it to be.

barseghyanartur avatar Feb 08 '19 08:02 barseghyanartur