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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:37:50+00:00 2026-06-05T15:37:50+00:00

In Django I have a SQL table with a column with a list of

  • 0

In Django I have a SQL table with a column with a list of dates. The field is DATE.

In the views.py file I would like to get a list of the years from those dates. I have tried the following with no luck:

from mysite.WeatherData.models import WeatherData

time_list =[]
raw_time_list = WeatherData.objects.all()

for onedatum in raw_time_list:
    time_list += onedatum.time_stamp.isocalendar()[0]

the column in WeatherData is called time_stamp and it holds the Date data.

The error I get is:
‘int’ object is not itterable.

I have done this with weeks of the year with WeatherData.objects.filter(location = LocationCode) and it worked fine so I’m not sure why this doesn’t work now.

  • 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-05T15:37:51+00:00Added an answer on June 5, 2026 at 3:37 pm

    You get that error because an integer cannot be appended to a list.
    Here is an example to reproduce the error:

    >>> l = []
    >>> l += 1
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: 'int' object is not iterable
    >>> l.append(1) # but we can use the .append() method instead
    >>> l
    [1]
    

    Applied to your code:

    for onedatum in raw_time_list:
        time_list.append(onedatum.time_stamp.isocalendar()[0])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL query in PostgreSQL that I'd like to translate to Django.
How do you load a database column into a list with Django? I have
I have a django project with an existing db that I would really like
I'm working in django project. I have 1 postgresql sql file that need to
I have Django set up under Windows (Win2008 Server R2, IIS 7.5, MS SQL).
In django, I have a table of people, each of which has a namefirst
I have a table describing files with a datetime field. I want to somehow
I have the following django model (mapped to table 'A'): class A(models.Model): name =
I have table invoices with field customer_id and some others fields. I need select
I'm creating a Django app in which I have a table which has 'items',

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.