[Answer]-Embedding text file into HTML

1👍

You’re going to need to get the contents of the text file into a string or something before you pass it to your template –

def your_view(request):
    #...
    f = item.content.open(mode='r')
    str = f.read()
    return render(request, {'file_content': str})

Then access the contents in your template with {{ file_content }}.

Leave a comment