Reputation: 21
I try to print the model object in a new line but my code doesn't work. Here is my code and I want to know how can I fix this problem?
def list_create_tasks(request):
if request.method == 'GET':
all_tasks=Task.objects.all()
return HttpResponse('\n'.join(map(str, all_tasks)))
Upvotes: 1
Views: 192
Reputation: 476574
HTML does not care about a new line. In order to write on a new line, you use the <br>
tag [w3schools]:
def list_create_tasks(request):
if request.method == 'GET':
all_tasks=Task.objects.all()
return HttpResponse('<br>'.join(map(str, all_tasks)))
Upvotes: 3