noirbizarre / django-eztables Goto Github PK
View Code? Open in Web Editor NEWEasy integration between jQuery DataTables and Django.
Home Page: http://django-eztables.readthedocs.org/en/latest/
License: GNU Lesser General Public License v3.0
Easy integration between jQuery DataTables and Django.
Home Page: http://django-eztables.readthedocs.org/en/latest/
License: GNU Lesser General Public License v3.0
by removing mimetype=JSON_MIMETYPE in eztables\views.py this error can be fixed
new view.py:
Would be useful (some say it is an absolute requirement) to have server side contente generated when JavaScript is disabled.
Or in other words: tables should work the same, even without JavaScript.
I got that error when installing your module from pypi. According to that issue:
There is a work aroung at least with easy_install.
Getting distribution for 'django-eztables'.
zip_safe flag not set; analyzing archive contents...
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1931, in main
with_ei_usage(lambda:
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1912, in with_ei_usage
return f()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1935, in
distclass=DistributionWithoutHelpCommands, **kw
File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 368, in run
self.easy_install(spec, not self.no_deps)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 588, in easy_install
return self.install_item(None, spec, tmpdir, deps, True)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 638, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 828, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1105, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1094, in run_setup
run_setup(setup_script, args)
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 30, in run_setup
lambda: execfile(
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 72, in run
return func()
File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 32, in
{'file':setup_script, 'name':'main'}
File "setup.py", line 76, in
File "/usr/lib/python2.7/distutils/core.py", line 152, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/dist-packages/setuptools/command/bdist_egg.py", line 241, in run
dry_run=self.dry_run, mode=self.gen_header())
File "/usr/lib/python2.7/dist-packages/setuptools/command/bdist_egg.py", line 538, in make_zipfile
visit(z, dirname, files)
File "/usr/lib/python2.7/dist-packages/setuptools/command/bdist_egg.py", line 528, in visit
z.write(path, p)
File "/usr/lib/python2.7/zipfile.py", line 1045, in write
zinfo = ZipInfo(arcname, date_time)
File "/usr/lib/python2.7/zipfile.py", line 295, in init
raise ValueError('ZIP does not support timestamps before 1980')
ValueError: ZIP does not support timestamps before 1980
An error occurred when trying to install django-eztables 0.3.2. Look above this message for any errors that were output by easy_install.
Hello,
I've got eztables listing model data for several models and it works great. I just noticed something strange today and was wondering if this is a bug or screwy code on my part. My models were already populated with data when I setup eztables. Any record with a pk of 0 is not displaying a valid URL, but instead just shows <pk>
. For records with PK of 1 and above the URL is correct.
Any ideas why that might be happening? I used Firebug to check my DOM and aaData actually has the proper PK of 0 returned. Normally my ID field is hidden in my HTML, but I set it to visible and the proper PK is there. It seems that my fnRender call is just not building the URL properly for a PK of 0.
I'm posting my js code that is being called, perhaps I have done something wrong since I am still new to eztables and datatables.
(function($, Django){
"use strict";
$(function(){
$('#dept-table').dataTable({
"bPaginate": true,
"sPaginationType": "bootstrap",
"bProcessing": true,
"bDeferRender": true,
"bServerSide": true,
"bAutoWidth" : false,
"sServerMethod": "POST", // pretty urls
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span12'i><'span12 center'p>>",
"oLanguage": {
"sLengthMenu": "_MENU_ records per page"
},
"sAjaxSource": Django.url('Dept_table_query'),
"aaSorting": [[ 1, "asc" ]], // Sort by this column descending
"aoColumns": [
{
"bSortable": false, // id column is not sortable
"bSearchable": false, // id column is not searcheable
"bVisible": true, // id column is hidden normally
"aTargets": [0],
},
{ "sWidth": "15%" }, // 1st column width
{ "sWidth": "63%" }, // 2nd column width
{
"mData": null,
"sWidth": "22%",
"bSortable": false, // column is not sortable
"bSearchable": false, // column is not searcheable
"fnRender": function (oObj) {
return ' <a href="' + Django.url('dept_detail', oObj.aData[0]) + '"><i ></i> View</a>'
+ ' <a href="' + Django.url('dept_update', oObj.aData[0]) + '"><i ></i> Edit</a>'
+ ' <a href="' + Django.url('dept_delete', oObj.aData[0]) + '"><i ></i> Delete</a>'
}
} // last, action column
],
});
});
}(window.jQuery, window.Django));
Thanks for any help
-Jay
Hi @noirbizarre,
There is a small bugfix in commit 3a6b492 that is necessary to be able to use eztables with Django 1.7 (just released yesterday). The latest version on pypi appears to be 0.3.2 though, which doesn't have the fix. Do you have any plans for 0.3.3?
Thanks,
Mat
Hi @noirbizarre
I install django-eztables with pip, but the result is error:
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/_x/p7ycmrps22vgm55mdwn1805w0000gn/T/pip_build_Meigan/django-eztables/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/_x/p7ycmrps22vgm55mdwn1805w0000gn/T/pip-6HH9qF-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/_x/p7ycmrps22vgm55mdwn1805w0000gn/T/pip_build_Meigan/django-eztables
Storing debug log for failure in /var/folders/_x/p7ycmrps22vgm55mdwn1805w0000gn/T/tmp9JhexD
Can you help me!
Bootstrap 3 requires a "pagination" class to be added to the ul element for the pager to look correct. Can this be added to the JS? Line 37 of datatables.bootstrap.js could read
'<ul class="pagination">'+
and it would work.
Demo doesn't work until you comment out this line from urls.py:
SpecialCasesDatatablesView,
Fantastic work and very easy to set up datatables (have it working with tabletools and editor = very nice).
However, I very quickly find myself needing/wanting to be able to pull in data using callbacks/querysets and similar. Is there anyway to do this?
Hey there I am having an issue with master the demo with the navigation not adding the class "pagination" to the <ul>
so that bootstrap might be able to stylize it.
I have come up with a workaround for the meantime in my dataTable() caller until you get back with me.
.on( 'init.dt',
function () {
$('.dataTables_paginate ul').addClass('pagination');
} )
Any ideas where I can make some modifications on a fork and send a pull request to apply the class to the appropriate <ul>
element?
I think the demo is busted looking too as the class isnt applying there either.
Hi everyone !
It's been a pleasure to develop and maintain this application for Django.
Unfortunately, I can't maintain it anymore, mostly because I'm not using Django anymore and I don't have the time to follow the new versions.
I will very soon migrate this repository here: https://github.com/djangojs
I'm currently looking for maintainers so anyone interested in, please comment here.
I'm just trying to get a DatatablesView to work with an EncryptedCharField, but it seems that the field decoding is not done (loading the encoded field via regular object loading works).
Is there any known solution for this?
Thanks
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
Not sure if you've abandoned this or just been too busy to update it but I can't help but feel like - as this is the 'official' repo it should be opened up so that the developers of some of the more active forks can help with development.
In the past I've had some success doing this the following way:
Hi,
I'm pretty new to django so hopefully everything I say will be correct.
If I add the primary key has a column text search will crash the app because pk__icontains is not a legal operation.
The simplest way I found to get around the problem is making the column not searchable. But this feature doesn't seem to be supported in eztables.
I've modified the global_search method the following way:
def global_search(self, queryset):
'''Filter a queryset with global search'''
search = self.dt_data['sSearch']
if search:
if self.dt_data['bRegex']:
criterions = [Q(**{'%s__iregex' % field: search}) for field in self.get_db_fields() if
self.can_regex(field)]
if len(criterions) > 0:
search = reduce(or_, criterions)
queryset = queryset.filter(search)
else:
search_fields = []
fields = self.fields.values() if isinstance(self.fields, dict) else self.fields
i = 0
for field in fields:
if self.dt_data['bSearchable_' + str(i)]:
if RE_FORMATTED.match(field):
search_fields.extend(RE_FORMATTED.findall(field))
else:
search_fields.append(field)
i += 1
for term in search.split():
criterions = (Q(**{'%s__icontains' % field: term}) for field in search_fields)
search = reduce(or_, criterions)
queryset = queryset.filter(search)
return queryset
Or is there another way of stoping the app from crashing with having the primary key (pk column) in the data?
Thank you
Hi there!
First of all i want to thx, eztable is GREATE!
but i stuck on custom filter (server-side date range). I've no idea how to call fnFilter with params that can be understan by class DatatablesView, Client side thats easy but i have huge data to show more than 50k rows for 1 table.
i dont wanna use php as ajaxsource, i want to use my models with view
I'm lammer i know but really need assistance.
Best regards
Robert
Hello,
Just a quick question about passing in arguments to the .url() function using eztables and django.js. How would one go about getting arguments from the URL?
Say for example you have a nice Django URL that looks like this
/building/list/1234/
And you want to pass in '1234' as an argument to your sAjaxSource, without hardcoding it
"sAjaxSource": Django.url('my_view', {arg1: '1234'})
How do you get access to that value in your eztables javascript?
Been hunting around and having found an easy way to do this.
Thanks for any suggestions!
-Jay
It seems that factory_boy is used in tests but its not a dependency so throws an error.
When setting bSort to false, it seems that “iSortingCols” isn't being passed in the GET, resulting in this error.
Not sure if I am missing something really simple but it seems that I get a 500 error if the model returns a datetime value for the table. See error below. Any help will be appreciated.
Incorrect datetime value: '%De%' for column 'post_time' at row 1
Hi,
Regexes on integer fields don't seem to work.
Thanks,
Jeff
Why is django.js a mandatory requirement for django-eztable?
As far as I know, we can use {% url %}
template tags instead. I use django-eztables on two websites and none of them use django.js.
I see four reasons why the template tag is better than django.js:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.