Giter Site home page Giter Site logo

Comments (8)

danmac-uk avatar danmac-uk commented on July 30, 2024

#45

I briefly tested the patch using one of the Django 1.7 betas and Python
2.7.6. Worked for me, so I decided to share it. I don't use Python 3
with Django, and can't see the error on your screen.

Cheers,

Dan.

On 23/07/14 15:58, David Fischer wrote:

Simply use |{{ datatable }}| with Django 1.7+ Python 3.4 and you will
get a nice error.

I guess that someone copy-pasted the class StrAndUnicode in utils.py
https://github.com/pivotal-energy-solutions/django-datatable-view/blob/master/datatableview/utils.py
from the project django_countries
https://bitbucket.org/mariocesar/django-countries/src/6ec34ad8418aa465aab4d24088afaa1bbb857ad4/django_countries/fields.py
without actually testing it.

|try:
from django.utils.encoding import StrAndUnicode
except ImportError:
from django.utils.encoding import python_2_unicode_compatible

 @python_2_unicode_compatible
 class StrAndUnicode:
     def __str__(self):
         return self.code

|
|


Reply to this email directly or view it on GitHub
#54.

from django-datatable-view.

davidfischer-ch avatar davidfischer-ch commented on July 30, 2024

Hello, I think it is quite obvious that the DatatableStructure does not have a "code" attribute.
I will make a pull request with my release that work for me. Please test it or explain me how to run tests,

Please add a tox.ini to this project to make it more easy to run tests + enable Travis CI hook.

from django-datatable-view.

danmac-uk avatar danmac-uk commented on July 30, 2024

Nice job :)

On 23/07/14 19:50, David Fischer wrote:

Hello, I think it is quite obvious that the DatatableStructure does
not have a "code" attribute.
I will make a pull request with my release that work for me. Please
test it or explain me how to run tests,

Please add a tox.ini to this project to make it more easy to run tests

  • enable Travis CI hook.


Reply to this email directly or view it on GitHub
#54 (comment).

from django-datatable-view.

davidfischer-ch avatar davidfischer-ch commented on July 30, 2024

You're welcome.

I am lucky to find a project like this one for helping me doing awesome tables :-)

from django-datatable-view.

danmac-uk avatar danmac-uk commented on July 30, 2024

I've only used it briefly so far, but yeah it's a really neat little tool :)

In addition to the previous issue with Django 1.7 that I stumbled
across, at least in my environment, I did have to hack around it with a
little Javascript to make it resize responsively along with the page. If
you're interested I would be happy to share that, although it's not
related directly to this project so I didn't create a pull request.

Cheers,

Dan.

On 23/07/14 20:07, David Fischer wrote:

You're welcome.

I am lucky to find a project like this one for helping me doing
awesome tables :-)


Reply to this email directly or view it on GitHub
#54 (comment).

from django-datatable-view.

davidfischer-ch avatar davidfischer-ch commented on July 30, 2024

You're awesome!

I discovered few minutes ago that the table isn't responsive but my website is (thanks to Bootstrap 3).

Eager to see your hack in action!

Thanks,

David

from django-datatable-view.

danmac-uk avatar danmac-uk commented on July 30, 2024

Haha thank you but I'm really not, still relatively new to Python and
Django compared to some :)

All I did was chuck this Javascript in below the table:


var update_size = function() {
$(DataTables_Table_0).css({ width:
$(DataTables_Table_0).parent().width() });
oTable.fnAdjustColumnSizing();
}

$(window).resize(function() {
clearTimeout(window.refresh_size);
window.refresh_size = setTimeout(function() { update_size(); }, 50);

});

I hope I'm safe in thinking it will be self-explanatory to you, but if
not feel free to let me know.

Hope this helps :)

Dan.

On 23/07/14 20:34, David Fischer wrote:

You're awesome!

I discovered few minutes ago that the table isn't responsive but my
website is (thanks to Bootstrap 3).

Eager to see your hack in action!

Thanks,

David


Reply to this email directly or view it on GitHub
#54 (comment).

from django-datatable-view.

tiliv avatar tiliv commented on July 30, 2024

Hey guys, sorry for the Django 1.7 issue. Looks like I confused the outcome of my testing of the code because 1.6 was the latest release and still included the (deprecated) StrAndUnicode import. Failure on my part to look at the pull request more closely than the passing tests!

I appreciate the pull request #55 to correct the issue. I've modified the strategy to avoid the StrAndUnicode base class, though. In the final commit d4bd4a0, I decided to just use the python_2_unicode_compatible utility directly (backported for earlier versions of Django), which is a graceful no-op function on python 3. I feel that this strategy makes Python 3 the first-class citizen in the code, which seems like the right thing to do!

Sorry again for the trouble!

For your convenience, you can run the provided tests using the included example project (it contains a manage.py and working settings.py):

$ cd django-datatable-view
$ datatableview/tests/example_project/manage.py test

You should know though that Django 1.7 changed some stuff about how apps are considered registered (something that is hacked in these tests to provide a separate set of test-only models), so the tests kind of blow up on the 1.7 release candidate right now. I need to sit down and work through that. Tests all pass on python 2 and python 3, if using Django 1.6 or earlier.

from django-datatable-view.

Related Issues (20)

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.