1

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)))

1 Answer 1

3

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)))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.