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 6123923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:04:25+00:00 2026-05-23T16:04:25+00:00

How do you load a database column into a list with Django? I have

  • 0

How do you load a database column into a list with Django? I have a ‘name’ column of various names in my database and I want to be able to load all those names (ordered by id) into a list. So that I can iterate over that list and print the names, like this:

for name in name_list:
      print name

I’ve googled this pretty thoroughly and I can’t find anything. This should be so simple, its just the equivalent of SQL’s “SELECT column FROM table”

class chat_messages(models.Model):
    name = models.CharField(max_length=32)
  • 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-05-23T16:04:25+00:00Added an answer on May 23, 2026 at 4:04 pm

    Check out the docs for values_list(). Django does a great job of creating the query specific to your request.

    chat_messages.objects.all().values_list('name')
    

    Will generate a query similar to:

    SELECT `projectname_chat_messages`.`name` FROM `projectname_chat_messages`
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a couple of CSV files I want to load into my database,
I need to load database content into a JTable . Many times I search
I am trying to load some info from the database asynchronously. I have a
How can I load XAML which is from the DataBase into the grid control
I have a .Net windows forms application, and I need to load values into
In order to load data (from a CSV file) into an Oracle database, I
I'm trying to Load a CSV file into my MySQL database, But I would
I have a MySQL database with a column of numeric value. When I query
I have an SQLite Database with 5000 rows that is loaded into a tableview.
I have an SQLite database with 4 tables in it that I want to

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.