GithubHelp home page GithubHelp logo

noirbizarre / django-eztables Goto Github PK

View Code? Open in Web Editor NEW
96.0 96.0 36.0 817 KB

Easy integration between jQuery DataTables and Django.

Home Page: http://django-eztables.readthedocs.org/en/latest/

License: GNU Lesser General Public License v3.0

Shell 1.41% Python 13.26% CSS 3.57% JavaScript 81.76%

django-eztables's People

Contributors

avoine avatar majochi avatar noirbizarre avatar swimlappy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-eztables's Issues

fallback for no JavaScript

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.

ZIP does not support timestamps before 1980

I got that error when installing your module from pypi. According to that issue:

NixOS/nixpkgs#270

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.

PK of 0 is not showing in generated URL

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

New PyPi release for Django 1.7

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

pip install issue

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!

Bootstrap3 pagination

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 broken

Demo doesn't work until you comment out this line from urls.py:

SpecialCasesDatatablesView,

Bootstrap pagination class

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.

Looking for maintainers

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.

Working with django-extensions EncryptedCharField

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

KeyError 'iColumns'

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

Handing over the reins?

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:

  1. Create a Github organization specifically for the project (i.e. 'django-eztables')
  2. Move the repo there and update PyPi links
  3. Reach out to the most active forkers to see if they'd like to join in and become a maintainer of the official repo.

Searchable collumns

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

server-side data-range

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

Pass URL param to eztables url()

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

Search filter with datetime values

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

Remove django.js from requirements

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:

  • less dependencies;
  • less code to download and execute for the client;
  • the template tag explicitly raises an exception when the view can't be found;
  • to me, django.js is a security flaw: allowing clients to reverse urls, access user permissions, and fetch CSRF tokens seems quite hazardous.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.