Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8862271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:41:20+00:00 2026-06-14T15:41:20+00:00

How do I display all the elements in a list with a line break

  • 0

How do I display all the elements in a list with a line break in a Django template?
For example, with a list
ls = ['bin', 'boot', 'data', 'data2'] I would like to display the elements in the format

bin
boot
data
data2

I have tried:

'\n'.join(ls)

This returns each word with spaces:

b i n b o o t d a t a d a t a 2

The relevant code from my views.py:

   result1 = subprocess.Popen(['ls', '/home/zurelsoft/R'], stdout=subprocess.PIPE).communicate()[0]
        result = ''.join(result1)
        return render_to_response('thanks.html', {'res':result, 'res1':command}, context_instance=RequestContext(request))

The corresponding section of the template:

<td>{{ res }} </td>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:41:21+00:00Added an answer on June 14, 2026 at 3:41 pm

    Modify your view to use the splitlines() function to split the output into a list of lines:

    def myview(request):
        result = subprocess.Popen(['ls', '/home/zurelsoft/R'], stdout=subprocess.PIPE).communicate()[0].splitlines()
        return render_to_response('thanks.html', {'res':result, 'res1':command}, context_instance=RequestContext(request))
    

    And then use the join filter in your template to separate each element in the list with the HTML line-break tag <br />:

    <td>{{ res|join:"<br/>" }}</td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to display all the subjects of email received on a website.
Is it possible to display all the query strings in Magento? I really like
I need to hide all list elements, but only show one at a certain
I'm attempting to display a table of data which looks like this on Windows
I'm trying to display all the products in an activity in a list of
I'm trying to display all the 'legs' for each of my 'trips' in my
I am trying to display all possible values for a sub-property. Below I am
I need to display all the employees in one webpart. I created the gridview
I need to display all enum values as tab items on TabControl, except one
i want to display all posts in Post table with say id=5 ...... controller

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.