[Fixed]-DJANGO DATATABLES template not working

1👍

✅

urlpatterns = patterns('SI.views',
                    url(regex=r'^', 
                    view='myModel_asJson',
                    name='url'),
)

There are a few issues in your code: the JSON call is on the root (I think that’s one of the issues) ! The view mixes up camel case and an underscore. The JSON call URL name is url. Apparently, you return user logins so better make your code explicit:

urlpatterns = patterns('SI.views',
    url(regex=r'^api/logins/', view='login_list', name='api-login-list'),
)

Change the view name as well of course. Then test it directly, go to http://localhost/api/logins/ to see if you get the proper list. Ideally, you want a functional test for that.

Finally, just change this in your template:
“url”: “{% url ‘api_login_list’ %}”,


Also in your view:

object_list = list(Utilisateur.objects.values_list("Login"))

Shouldn’t it be login? No uppercase.

Leave a comment