Все, что я пытаюсь сделать, это через Django отобразить мою таблицу CSV на странице. И все, кажется, работает, но по какой-то причине я получаю ошибку, и я не могу найти решение ее
ValueError: The view csv_app.views.csv_simple_read didn't return an HttpResponse object. It returned None instead.
[19/Feb/2020 21:40:07] "GET / HTTP/1.1" 500 57986
Я новичок в django. Буду очень признателен за любую помощь.
Views.py
import csv
import os
def csv_simple_read(request):
path = os.path.dirname(__file__)
file = os.path.join(path, 'csv_simple_read.csv')
with open(file) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=';')
line_count = 0
for row in csv_reader:
print('\n\nColumn names are {}, {}, {}, {}'.format(row[0], row[1], row[2], row[3]))
line_count += 1
csv_simple_read.csv
test3;2020-02-16;05:22:49;OK
test2;2020-02-16;05:22:25;OK
test1;2020-02-16;05:22:10;OK
test3;2020-02-16;05:22:49;OK
test2;2020-02-16;05:22:25;OK
test1;2020-02-16;05:22:10;OK
csv_home. html
<body>
<h3>CSV Example - Read Write Examples</h3>
<ul>
<br>
<li>Read Operation
<ul>
<li>
<a href="{% url 'csv_simple_read' %}">Simple CSV Read Operation</a>
</li>
</ul>
</li>
</ul>
{{csv_data}}
{% if csv_data %}
sad
{{csv_data}}
{% endif %}
</body>