django_tables2 패키지를 사용하여 내 페이지에 테이블을 표시하고 있습니다. 동적으로 표시하고자하는 두 가지 데이터 집합이 있습니다. 내 views.py에서Django 테이블이있는 동적 테이블
<Table_1_A>
<Table_1_B>
<Table_2_A>
<Table_2_B>
<Table_n_A>
<Table_n_B>
내가 가진 :
primary_keys = {1, 2, ... n} # these are not simple or ordered integers
tables_A = {}
tables_B = {}
for primary_key in primary_keys:
tables_A['primary_key'] = TableA(table_A_queryset.filter(pk=primary_key))
RequestConfig(request).configure(tables_A[primary_key])
tables_B['primary_key'] = TableB(table_B_queryset.filter(pk=primary_key))
RequestConfig(request).configure(tables_B[primary_key])
return render(request, 'index.html', {'primary_keys': primary_keys, 'tables_A ': tables_A , 'tables_B ': tables_B })
TableA의와 TableB의 나의 tables.py 내 templatetabs 폴더에서
을에 정의되어 내가 가진 tags.py :
@register.assignment_tag
def get_table(table, primary_key):
return table.get(primary_key)
마지막으로 내 index.html에 :
{% load render_table from django_tables2 %}
{% load tags %}
{% block content %}
{% for primary_key in primary_keys %}
<div class="data_tables">
{% get_table tables_A primary_key as table_A %}
{% render_table table_A %}
<br>
<br>
{% get_table tables_B primary_key as table_B%}
{% render_table table_B%}
</div>
{% endfor %}
{% endblock content %}
pycharm에서 django 1.11을 실행 중이며 pycharm에서 실행 중이면 정상적으로 작동합니다. 데비안 서버에서 실행하면 오류가 발생합니다. primary_key, tables_A 및 tables_B로 전달 된 것이 있으면 500 내부 서버 오류가 발생합니다. 그 사전들이 비어 있다면 나는 '19 번 줄에 잘못된 블록 태그가있다.'get_table ','empty '또는'endfor '가 예상된다. 이 태그를 등록하거나로드하는 것을 잊었습니까? '
이것은 서버에서 작동하지 않지만 로컬에서 작동하는 이유는 무엇입니까? 아니면 이것을 할 수있는 더 좋은 방법이 있습니까?