ajax and search
joeyac opened this issue · 4 comments
when I set ajax to true,the search model seems to be error ,can you solve this?
Can you give more details? What is your error exactly?
Hi, looks like the problem is when you have a foreign key table:
10:59:39 AM web.1 | Internal Server Error: /table/ajax/bf36a02d72149d056fb3c275ccfe2846/ 10:59:39 AM web.1 | Traceback (most recent call last): 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response 10:59:39 AM web.1 | response = self.process_exception_by_middleware(e, request) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response 10:59:39 AM web.1 | response = wrapped_callback(request, *callback_args, **callback_kwargs) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view 10:59:39 AM web.1 | return self.dispatch(request, *args, **kwargs) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/views/generic/base.py", line 88, in dispatch 10:59:39 AM web.1 | return handler(request, *args, **kwargs) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/table/views.py", line 53, in get 10:59:39 AM web.1 | return BaseListView.get(self, request, *args, **kwargs) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/views/generic/list.py", line 174, in get 10:59:39 AM web.1 | context = self.get_context_data() 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/table/views.py", line 130, in get_context_data 10:59:39 AM web.1 | queryset = self.filter_queryset(queryset) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/table/views.py", line 77, in filter_queryset 10:59:39 AM web.1 | queryset = queryset.filter(get_filter_arguments(target)) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/db/models/query.py", line 790, in filter 10:59:39 AM web.1 | return self._filter_or_exclude(False, *args, **kwargs) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/db/models/query.py", line 808, in _filter_or_exclude 10:59:39 AM web.1 | clone.query.add_q(Q(*args, **kwargs)) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1243, in add_q 10:59:39 AM web.1 | clause, _ = self._add_q(q_object, self.used_aliases) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1263, in _add_q 10:59:39 AM web.1 | current_negated, allow_joins, split_subq) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1269, in _add_q 10:59:39 AM web.1 | allow_joins=allow_joins, split_subq=split_subq, 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/db/models/sql/query.py", line 1194, in build_filter 10:59:39 AM web.1 | lookup_class = field.get_lookup(lookups[0]) 10:59:39 AM web.1 | File "/Users/mhcristian/proyectos/cloaker/venv/lib/python2.7/site-packages/django/db/models/fields/related.py", line 693, in get_lookup 10:59:39 AM web.1 | raise TypeError('Related Field got invalid lookup: %s' % lookup_name) 10:59:39 AM web.1 | TypeError: Related Field got invalid lookup: icontains
which error? ajax error? That `s because some columes are made of fields of function, you have to make that columes searchable=false
Hello! I found this same error! how was it solved?
It only happened when using ajax with a model that has a fk.
I just solve this by adding my FK model field into the table.
class ExamenTable(Table):
id = Column(field='id', header=u'ID')
materia = Column(field='curso.materia.nombre_materia', header='Materia')