Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError 'iColumns' #25

Open
t-navi opened this issue Jun 7, 2014 · 3 comments
Open

KeyError 'iColumns' #25

t-navi opened this issue Jun 7, 2014 · 3 comments

Comments

@t-navi
Copy link

t-navi commented Jun 7, 2014

Hi.
When I trying to look what kind of json will be

view.py

class TempDatatablesView(DatatablesView):
    model = Deal
    fields = (
         'deal_name',
    )

url.py

 url(r'^test/$', TempDatatablesView.as_view(), name='deals_list_json'),

I catch exeption:

in eztables/forms.py in init, line 22

for idx in xrange(int(self.data['iColumns'])): 

Python Version: 2.7.6
Django Version: 1.6.5

@MatMoore
Copy link

This problem is caused by the API changing in Datatables.net 1.10.

To fix it we need to parse the parameters defined here:
https://datatables.net/manual/server-side

This is slightly annoying as it doesn't send through the number of columns/order columns anymore, and django doesn't parse the arrays; I get separate values for
columns[0][data]
columns[1][data]
etc.

The problem seems to be localised to DatatablesForm - if I modify the request data on the way in the generated output appears to work fine with the new datatables.

@noirbizarre do you have any thoughts on this? I'm not really sure what the cleanest way to handle both new/old versions would be.

There is a workaround described at https://datatables.net/manual/server-side#Legacy - passing through sAjaxSource instead of ajax on the javascript side.

@Venom57
Copy link

Venom57 commented Aug 24, 2014

I'm experiencing this same issue with just the DatatablesView as the OP was.

I've tried to use the Legacy support mode as suggested by @MatMoore but I'm still receiving the KeyError. It looks like it's happening between the url and view code, i.e. commenting out all table generation in my template still throws the same error.

@matlads
Copy link

matlads commented Nov 3, 2014

Any update on this issue? I am currently running into this same exact issue. Did any workaround get created?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants