pivotal-energy-solutions/django-datatable-view

fixes to make it work with django 2.0 and python 3

Z0t opened this issue · 4 comments

Z0t commented

To make the examples work I had to:

Add on_delete to ForeignKey:
- example = models.ForeignKey('ExampleModel')
+ example = models.ForeignKey('ExampleModel',on_delete=models.CASCADE)

Replace .rel with remote_field:
- if hasattr(field, 'rel') and field.rel: # Forward/m2m relationship
- return field.rel.to
+ if hasattr(field, 'remote_field') and field.remote_field: # Forward/m2m relationship
+ return field.remote_field.model

Use urls, and not core.urlresolvers:
-from django.core.urlresolvers import reverse
+from django.urls import reverse

0001-Hacks-to-make-it-work-with-django-and-python3.patch.zip

Do you have it running well with django 2? I used your fixes and it runs well, but now I cannot use runserver to debug. It throws a 'stack overflow' error. It seems that this is the problem:

    # Template rendering features
    def __str__(self):
        """ Renders ``structure_template`` with ``self`` as a context variable. """

        if not hasattr(self, 'config'):
            self.configure()

        context = {
            'url': self.url,
            'config': self.config,
            'datatable': self,
            'columns': self.columns.values(),
        }
        return render_to_string(self.config['structure_template'], context)

I am not sure what could be wrong. The code is taken from datatables.py line 901. I can use runserver_plus just fine, and it works in production as well.

Z0t commented

Not sure, I was running latest versions of everything when I did the diff.

@jangeador I also have a >2.0 version working, check my branch if you need it: doganmeh/django-datatable-view

so... #206 (comment) does the zip work?
I also need django 2.0 and python3