yourlabs / django-autocomplete-light

A fresh approach to autocomplete implementations, specially for Django. Status: v4 alpha, v3 stable, v2 & v1 deprecated.
https://django-autocomplete-light.readthedocs.io
MIT License
1.8k stars 467 forks source link

Add compatibility with django-hstore #340

Open bufke opened 9 years ago

bufke commented 9 years ago

This project is currently incompatible with django-hstore schema mode. hstore introduces it's own VirtualField. I've demonstrated the issue here.

autocomplete expects ._meta.virtual_fields to contain a fk_field property here. However the hstore VirtualField does not have a fk_field.

for field in meta.model._meta.virtual_fields:
    ...
    required=not meta.model._meta.get_field_by_name(field.fk_field)

A check if hasattr(field, 'fk_field'): fixes the issue and I can't see it causing any harm. Would you consider a pull request to support this? If you feel this is better solved on django-hstore's end please let me know. I'd love to get a fix accepted on one of the projects.

See issue on django-hstore too.

jpic commented 9 years ago

Hstore is cool and we should support it optionaly. I would love to have a look at a poc please make sure you get all info from docs.yourlabs.org On Nov 29, 2014 6:52 PM, "David Burke" notifications@github.com wrote:

This project is currently incompatible with django-hstore schema mode. hstore introduces it's own VirtualField https://github.com/djangonauts/django-hstore/blob/master/django_hstore/virtual.py. I've demonstrated the issue here https://github.com/bufke/autocomplete_hstore.

autocomplete expects ._meta.virtual_fields to contain a fk_field property here https://github.com/yourlabs/django-autocomplete-light/blob/stable/2.x.x/autocomplete_light/forms.py#L358. However the hstore VirtualField does not have a fk_field.

for field in meta.model._meta.virtual_fields: ... required=not meta.model._meta.get_field_by_name(field.fk_field)

A check if hasattr(field, 'fk_field'): fixes the issue and I can't see it causing any harm. Would you consider a pull request to support this? If you feel this is better solved on django-hstore's end please let me know. I'd love to get a fix accepted on one of the projects.

See issue https://github.com/djangonauts/django-hstore/issues/86 on django-hstore too.

— Reply to this email directly or view it on GitHub https://github.com/yourlabs/django-autocomplete-light/issues/340.

jpic commented 9 years ago

Isn't this fixed with master or 2.1.0rc2 ?

jpic commented 8 years ago

Well have a test in 2.3.