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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:31:41+00:00 2026-06-12T17:31:41+00:00

I am following a Django tutorial, and I have run into a problem with

  • 0

I am following a Django tutorial, and I have run into a problem with one of my views. When looking at the error output from django it tells me that there is a error on line 62:

yr = datetime.datetime(year, 1, 1)     months = 12

Here is the entire view:

def year(request):
    #http://site_name/year/
    post_error = ""
    year = int(year)
    yr = datetime.datetime(year, 1, 1)     months = 12
    by_month = []
    if Post.objects.filter(published__year=year).count():
    if year == datetime.datetime.now().year:
        months = datetime.datetime.now().month
    for month in range(1, months+1):
        by_month.append({datetime.datetime(year, month, 1):

    Post.objects.filter(published__month=month).filter(published__year=year)})
    elif year > datetime.datetime.now().year:
    post_error = "It is not yet %d, try an earlier year." % year
    else:
    post_error = "There are not posts for %d." % year
    return render_to_response('year.html', {'by_month':by_month, 'post_error':post_error,},)

Please tell me if you need anymore information that I have not provided. Thanks! -Chris

  • 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-12T17:31:42+00:00Added an answer on June 12, 2026 at 5:31 pm

    You have two statements on one line; that’s a syntax error. Put them on two separate lines:

    yr = datetime.datetime(year, 1, 1)
    months = 12
    

    Technically, you could also join multiple statements with a ; semi-colon, but that is generally discouraged.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following the Django-CMS introductory tutorial and have got everything working up to the
I am following the django tutorial here . I have copied everything exactly. After
I'm following the Django tutorial and got stuck with an error at part 4
I'm just learning django and following a tutorial. I have a Link and a
Following the Heroku tutorial but I have already created a rather complex Django app
I am trying to upload an image using django and following a tutorial from
I developed a simple Django/Python poll application(Following step by step tutorial from the Django
I am following the Django tutorial and have made it to Decoupling the URLConfs
In Django how do you remove models that you have synced into the database?
After following the tutorial for Django, I have the baseline of my app up

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.