Пожалуйста, почему я получаю следующую ошибку:
Caught NameError while rendering: global name 'name' is not defined.
Первоначально я не получил такого рода ошибки, он просто всплыл все
внезапно Я восстановил свое приложение до состояния, где все работало
и я все еще получаю ту же ошибку.
Полная трассировка стека:
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
Более подробная информация в шаблоне трассировки назад
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">
В моем файле шаблона:
{% 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 %}
Когда я удаляю приведенный выше код из моего шаблона, ошибка исчезает, но
строки таблицы не отображаются.
код из 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})
Любые предложения, пожалуйста.
Спасибо