Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boolean columns break rendering #360

Closed
wtfrank opened this issue Jul 30, 2016 · 5 comments
Closed

Boolean columns break rendering #360

wtfrank opened this issue Jul 30, 2016 · 5 comments

Comments

@wtfrank
Copy link

wtfrank commented Jul 30, 2016

If you specify a BooleanColumn, that column doesn't render, nor do the columns to the right of the BooleanColumn. The following simple change to the example app demonstrates the issues with the bootstrap table (screenshot here http://imgur.com/a/0QQW4).

diff --git a/example/app/models.py b/example/app/models.py
index 74818d2..b4ed209 100644
--- a/example/app/models.py
+++ b/example/app/models.py
@@ -32,6 +32,7 @@ class Country(models.Model):

 class Person(models.Model):
     name = models.CharField(max_length=200, verbose_name='full name')
+    friendly = models.BooleanField()

     country = models.ForeignKey(Country, null=True)

diff --git a/example/app/tables.py b/example/app/tables.py
index fe7da67..05d51ca 100644
--- a/example/app/tables.py
+++ b/example/app/tables.py
@@ -22,11 +22,13 @@ class ThemedCountryTable(CountryTable):

 class BootstrapTable(tables.Table):

+    friendly = tables.BooleanColumn()
     country = tables.RelatedLinkColumn()

     class Meta:
         model = Person
         template = 'django_tables2/bootstrap.html'
+        sequence=('country', 'friendly', '...')


 class PersonTable(tables.Table):

This occurs with django 1.9.8 / django-tables2 1.2.4 (and latest from github) / python 2.7.12

@jieter
Copy link
Owner

jieter commented Jul 30, 2016

Thanks for reporting, can you also have a look at the generated HTML?

@wtfrank
Copy link
Author

wtfrank commented Jul 30, 2016

TD cells only exist for the country column (the only column that is rendered)

     <tbody>


                        <tr class="even">

                                <td class="country"><a href="country/1">Australia</a></td>

                        </tr>



                        <tr class="odd">

                                <td class="country"><a href="country/4">Canada</a></td>

                        </tr>

Whereabouts in the code should the other columns be getting rendered?

@jieter
Copy link
Owner

jieter commented Jul 30, 2016

Hmm, turns out the try-catch I removed in b4045ca was not so redundant. I'll try to add a test to check this and release after that.

@wtfrank
Copy link
Author

wtfrank commented Jul 30, 2016

I've just tested putting that try/catch back in and it solves the issue in that example app and also the real application that I discovered the fault in.

@wtfrank
Copy link
Author

wtfrank commented Jul 30, 2016

BTW its the StopIteration exception from the next() call that gets trapped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants