djangonauts / django-hstore

PostgreSQL HStore support for Django.
http://django-hstore.readthedocs.io/
Other
517 stars 142 forks source link

Schema mode is incompatible with django-autocomplete-light #86

Closed bufke closed 9 years ago

bufke commented 9 years ago

I made a repo showing the issue at https://github.com/bufke/autocomplete_hstore

When using autocomplete-light with schema mode I get AttributeError: 'VirtualField' object has no attribute 'fk_field'

If you remove the schema from here it will run fine.

I'm not sure if this should be a report for autocomplete instead. Let me know what you think. I'll try thinking of a fix too.

web_1 | Traceback (most recent call last):
web_1 |   File "manage.py", line 10, in <module>
web_1 |     execute_from_command_line(sys.argv)
web_1 |   File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
web_1 |     utility.execute()
web_1 |   File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
web_1 |     django.setup()
web_1 |   File "/usr/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
web_1 |     apps.populate(settings.INSTALLED_APPS)
web_1 |   File "/usr/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
web_1 |     app_config.ready()
web_1 |   File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/apps.py", line 22, in ready
web_1 |     self.module.autodiscover()
web_1 |   File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 23, in autodiscover
web_1 |     autodiscover_modules('admin', register_to=site)
web_1 |   File "/usr/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
web_1 |     import_module('%s.%s' % (app_config.name, module_to_search))
web_1 |   File "/usr/local/lib/python2.7/importlib/__init__.py", line 37, in import_module
web_1 |     __import__(name)
web_1 |   File "/code/demo/admin.py", line 6, in <module>
web_1 |     class SomethingAdmin(admin.ModelAdmin):
web_1 |   File "/code/demo/admin.py", line 7, in SomethingAdmin
web_1 |     form = autocomplete_light.modelform_factory(SomethingWithSchema)
web_1 |   File "/usr/local/lib/python2.7/site-packages/autocomplete_light/forms.py", line 443, in modelform_factory
web_1 |     {'Meta': Meta})
web_1 |   File "/usr/local/lib/python2.7/site-packages/autocomplete_light/forms.py", line 269, in __new__
web_1 |     cls.post_new(new_class, meta)
web_1 |   File "/usr/local/lib/python2.7/site-packages/autocomplete_light/forms.py", line 339, in post_new
web_1 |     cls.add_generic_fk_fields(new_class, meta)
web_1 |   File "/usr/local/lib/python2.7/site-packages/autocomplete_light/forms.py", line 358, in add_generic_fk_fields
web_1 |     field.fk_field)
web_1 | AttributeError: 'VirtualField' object has no attribute 'fk_field'
nemesifier commented 9 years ago

I don't understand your question.

Do you intend to add support for this package or do you think it's a bug?

If you think it's a bug, write a failing test case for it first. If you intend to add support for the package you mentioned outline your idea.

bufke commented 9 years ago

I intent to add support but I'm unsure how to approach it. How robust should VirtualField be? Should we work to make 3rd party apps accept VirtualField as a fairly typical field? I determined it also fails with django-report-builder which introspects model fields. Or should I work on these other apps to explicitly support django-hstore's VirtualField.

Without much knowledge of all these codebases - I'd guess it would best to try getting VirtualField to work automatically with these 3rd party apps. If that proves difficult or impossible then the 3rd party apps will have to explicitly support django-store. Thoughts?

nemesifier commented 9 years ago

I think it is not possible to add support for every possible case right now. Work on the case you need right now.

On 11/28/2014 11:02 PM, David Burke wrote:

I intent to add support but I'm unsure how to approach it. How robust should VirtualField be? Should we work to make 3rd party apps accept VirtualField as a fairly typical field? I determined it also fails with django-report-builder which introspects model fields. Or should I work on these other apps to explicitly support django-hstore's VirtualField.

Without much knowledge of all these codebases - I'd guess it would best to try getting VirtualField to work automatically with these 3rd party apps. If that proves difficult or impossible then the 3rd party apps will have to explicitly support django-store. Thoughts?

— Reply to this email directly or view it on GitHub https://github.com/djangonauts/django-hstore/issues/86#issuecomment-64931075.