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

  • Home
  • SEARCH
  • 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 8856229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:18:40+00:00 2026-06-14T14:18:40+00:00

67 <h2>Latest Posts</h2> 68 69 <ul> 70 {% for post in posts %} 71

  • 0
67  <h2>Latest Posts</h2>
68  
69  <ul>
70      {% for post in posts %}
71              <li><a href="{{ post.get_absolute_url }}">{{post.title}}</a></li>
72      {% endfor %}
73  </ul>

this is my base template and when i click a post,getting an error at line 70:

TypeError at /blog/posts/indiana-was-dogs-name/
'Blog' object is not iterable

my blog models:

class Blog(models.Model):
    title = models.CharField(max_length=100, unique=True)
    slug = models.SlugField(max_length=100, unique=True)
    body = models.TextField()
    posted = models.DateField(db_index=True, auto_now_add=True)
    category = models.ManyToManyField(Category)


    def __unicode__(self):
        return self.title

    def get_absolute_url(self):
        return "/blog/posts/%s/" % self.slug

my index view:

def index(request):

    variables = RequestContext(request, {
                                         'categories': Category.objects.all(),
                                         'posts': Blog.objects.filter(posted__lte=datetime.now()).order_by('-posted', 'title')
                                        })
    return render_to_response('index.html',variables)

there are a few posts about error like this but not including my problem

  • 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-14T14:18:42+00:00Added an answer on June 14, 2026 at 2:18 pm

    As it says, the blogs variable you pass to your template is not iterable.
    You can only iterate through lists and other iterables, and in your case, blogs is a Blog instance, where it should be a QuerySet. You may write, for example

    blogs = Blog.objects.all()
    return render_to_response(..., {'blogs':blogs,...} ...}
    

    Edit

    I would feel more safe if you used the exact syntax given in the Django docs. Maybe the difference of syntax is the culprit, I really don’t see yet otherwise.

    render_to_response(template_name[, dictionary][, context_instance][, mimetype])
    

    with dictionary set to {'categories': Category.objects.all(), 'posts': Blog.objects.filter(posted__lte=datetime.now()).order_by('-posted', 'title')} and context_instance=RequestContext(request)

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

Sidebar

Related Questions

I'm trying to create a post button that inserts the latest posts into a
I know this will let the user retrieve the latest 10 posts from cocacola
Let's say I have this code which gets the latest posts via ajax: $.ajax({
I am trying to retrieve the latest 5 posts (by post time) In the
I have a template file ( trendingPosts.php ) for showing 2 latest posts with
I am getting the latest posts of all categories using the code below. I
I have written this code to loop through the latest 6 posts on my
I tried this select posts.id, posts.title from posts inner join ( select post_id,max(created) from
How would you refactor this logic filled partial? <%- for post in @posts -%>
I'm trying to show latest Post Excerpt, Post Title and Featured Image on an

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.