{django-tables} Caught NameError on rendering: global name 'name' not defined

Please, why am I getting the following error:

Caught NameError while rendering: global name 'name' is not defined. 

Initially, I did not get such an error, it just surfaced suddenly. I restored the application to the state where everything worked and I still get the same error.

Full stack trace:

 Caught NameError while rendering: global name 'name' is not defined Request Method: GET Request URL: http://site/reports Django Version: 1.3 Exception Type: TemplateSyntaxError Exception Value: Caught NameError while rendering: global name 'name' is not defined Exception Location: build\bdist.win32\egg\django_tables\models.py in _default_render, line 73 Python Executable: C:\path\apache\apache2.2.10\bin\httpd.exe Python Version: 2.7.1 

Learn more about template tracing.

 Template error In template c:\path\to\project\templates\webapp\reports.html, error at line 41 Caught NameError while rendering: global name 'name' is not defined 31 {% for column in table.columns %} 32 <th {% if forloop.first %} class="first" {% endif %} {% if forloop.last %} class="last" {% endif %} class="table-header"> 33 {% if column.sortable %} 34 <a href="?sort={{ column.name_toggled }}"> 35 {{ column }} 36 </a> 37 {% endif %} 38 </th> 39 {% endfor %} 40 </tr> 41 {% for row in table.rows %} 42 <tr class="{% cycle 'odd' 'even' %}"> 43 {% for value in row %} 44 <td class="table-data">{{ value }}<td> 45 {% endfor %} 46 </tr> 47 {% endfor %} 48 </tbody> 49 </table> 50 <div class="actions-bar wat-cf"> 51 <div class="actions"> 

In my template file:

 {% load humanize %} {% load tables %} {% load pagination_tags %} {% autopaginate rows 2 %} {% for row in table.rows %} <tr class="{% cycle 'odd' 'even' %}"> {% for value in row %} <td class="table-data">{{ value }}<td> {% endfor %} </tr> {% endfor %} 

When I remove the above code from my template, the error goes away, but the table rows are not displayed.

code from views.py

 class TransactionReport(tables.ModelTable): identifier = tables.Column(sortable=False, visible=False) created = tables.Column(sortable=True, visible=True) @classmethod def get_reports_paid(self, object, req): return TransactionReport(object, order_by=req) class Meta: model = Transaction @login_required def display_reports(request): logger = logging.getLogger(__name__) dataqs = Transaction.objects.filter(paid="TRUE") req = request.GET.get('sort', 'created') tx = TransactionReport().get_reports_paid(dataqs, req) return render_to_response('webapp/reports.html', {'table': tx, 'rows' : tx.rows}) 

Any suggestions please.

thanks

+1
source share

Source: https://habr.com/ru/post/910821/


All Articles