title: Django - 'function' object is not iterable - Error during template rendering
body: <p>So, I've been trying to create a user login. When I click submit on my login form, I get this error:</p>
  
  <pre><code>Exception Type: TypeError
  Exception Value: 'function' object is not iterable 
  </code></pre>
  
  <p>Here's the full Traceback: <a href="http://dpaste.com/3D1B7MG" rel="nofollow">http://dpaste.com/3D1B7MG</a></p>
  
  <p>So, If I'm reading the Traceback correctly, the problem is in the <strong>{% extends "base.html" %}</strong> line of all_poss.html. So would that would mean the problem is actually inside base.html? or in the view that controls all_posts?</p>
  
  <p>My all_posts.html</p>
  
  <pre><code>{% extends "base.html" %}
  {% load staticfiles %}
  
  &lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;style&gt;&lt;/style&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>base.html</p>
  
  <pre><code>{% load staticfiles %}
  {% load crispy_forms_tags %}
  
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
     "http://www.w3.org/TR/html4/strict.dtd"&gt;
  &lt;HTML&gt;
     &lt;HEAD&gt;
         &lt;link rel="stylesheet"     href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"&gt;
         &lt;link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css"&gt;
         &lt;link rel="stylesheet" href="{% static 'css/base.css' %}"&gt;
         &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
         &lt;link href="assets/css/bootstrap-responsive.css" rel="stylesheet"&gt;
        &lt;TITLE&gt;{% block title %}{% endblock %}&lt;/TITLE&gt;
  
  &lt;/HEAD&gt;
  
     &lt;BODY&gt;
     {% block content %}
     &lt;div class="navbar-wrapper"&gt;
     &lt;div class="post_button" style="width:58px; margin:0 auto;"&gt;
     &lt;a href="#" class="btn btn-custom blue"&gt;Submit a Post&lt;/a&gt;
     &lt;/div&gt; &lt;!-- /.post_button--&gt;
     &lt;div class="log_bar"&gt;
      &lt;ul&gt;
          {% if user.is_authenticated %}
              &lt;li&gt;Welcome,&lt;/li&gt;
              &lt;li&gt;&lt;a href="{% url 'profile' %}"&gt;{{ user.username }}&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;|&lt;/li&gt;
              &lt;li&gt;&lt;a href="{% url 'logout' %}"&gt;Log Out&lt;/a&gt;&lt;/li&gt;
          {% else %}
              &lt;li&gt;Please&lt;/li&gt;
              &lt;li&gt;&lt;a data-toggle="modal" data-target="#modal-login" href=""&gt;log in&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;or&lt;/li&gt;
              &lt;li&gt;&lt;a data-toggle="modal" data-target="#modal-register" href=""&gt;sign up&lt;/a&gt;&lt;/li&gt;
          {% endif %}
      &lt;/ul&gt;
      &lt;/div&gt;&lt;!-- /.log_bar --&gt;
  &lt;nav class="navbar navbar-fixed-left navbar-static-top"&gt;
    &lt;div class="container-fluid"&gt;
      &lt;!-- Collect the nav links, forms, and other content for toggling --&gt;
        &lt;ul class="nav navbar-nav "&gt;
          &lt;li class="active"&gt;&lt;a href="/"&gt;Home &lt;span class="sr-only"&gt;(current)&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=""&gt;All&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=""&gt;New&lt;/a&gt;&lt;/li
          &lt;li class="dropdown"&gt;
            &lt;a href="" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"&gt;Top&lt;span class="caret"&gt;&lt;/span&gt;&lt;/a&gt;
            &lt;ul class="dropdown-menu"&gt;
            &lt;li&gt;&lt;a href=""&gt;hour&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=""&gt;24 hrs&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=""&gt;week&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=""&gt;month&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=""&gt;year&lt;/a&gt;&lt;/li&gt;
            &lt;li&gt;&lt;a href=""&gt;beginning of time&lt;/a&gt;&lt;/li&gt;
              &lt;li role="separator" class="divider"&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=""&gt;Custom Search&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/div&gt;&lt;!-- /.container-fluid --&gt;
  &lt;/nav&gt;
  &lt;div id="side_bar"&gt;
       &lt;form class="navbar-form navbar-static-top navbar-right" role="search" id="navBarSearchForm"&gt;
                  &lt;div class="input-group"&gt;
                      &lt;input type="text" class="form-control" placeholder="Search"&gt;
                      &lt;span class="input-group-btn"&gt;
                          &lt;button type="submit" class="btn btn-default" id="search_btn"&gt;
                          &lt;span class="glyphicon glyphicon-search"&gt;&lt;/span&gt;
                          &lt;/button&gt;
                      &lt;/span&gt;
              &lt;/div&gt;
              &lt;/form&gt;
      &lt;/div&gt;&lt;!-- /.side-bar --&gt;
      &lt;button class="btn-block" id='hideshow' value='hide/show' style="display: block; height: 100%;"&gt;&lt;/button&gt;
  
      {% include 'register.html' %}
      {% include 'login.html' %}
  
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;    &lt;/script&gt;
      &lt;script  src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"&gt; &lt;/script&gt;
      &lt;script type="text/javascript" src="{{ STATIC_URL }} /static/jquery.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="{{ STATIC_URL }} /static/jquery.leanModal.js"&gt;&lt;/script&gt;
  
  {% endblock %}
     &lt;/BODY&gt;
  &lt;/HTML&gt;
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def login(request):
      """
      Log in view
      """
      if request.method == 'POST':
          form = AuthenticationForm(data=request.POST)
          if form.is_valid():
              user = authenticate(username=request.POST['username'], password=request.POST['password'])
              if user is not None:
                  if user.is_active:
                      django_login(request, user)
                      return render(request, 'all_posts.html', {'user': request.user})
      else:
          form = AuthenticationForm()
      return render_to_response('login.html', {
          'authenticationform': form,
      }, context_instance=RequestContext(request))
  
  
  def all_posts(request):
      post_list = TextPost.objects.all().order_by('-score'))
      paginator = Paginator(post_list, 100) # Show 100 contacts per page
      registrationform = RegistrationForm(request.POST or None)
      authenticationform = AuthenticationForm(request.POST or None)
  
      page = request.GET.get('page')
  
      try:
          posts = paginator.page(page)
      except PageNotAnInteger:
          # If page is not an integer, deliver first page.
          posts = paginator.page(1)
      except EmptyPage:
          # If page is out of range (e.g. 9999), deliver last page of results.
          posts = paginator.page(paginator.num_pages)
  
      return render(request, 'all_posts.html', {'posts': posts,     'registrationform': registrationform, 'authenticationform': authenticationform, 'user': request.user})
  </code></pre>
  
  <p><strong>Edit 1: login.html</strong> login.html and register.html are identical modals, one with a login form and the other with the registration one.</p>
  
  <pre><code>{% load staticfiles %}
  {% load crispy_forms_tags %}
  
  &lt;div class="modal" id="modal-login"&gt;
          &lt;div class="modal-dialog"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;form enctype="multipart/form-data" method="post" action="login/"&gt;
                      &lt;div class="modal-header"&gt;
                          &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
                          &lt;h3 class="modal-title"&gt;Log In&lt;/h3&gt;
                      &lt;/div&gt;
                      &lt;div class="modal-body"&gt;
                          {% csrf_token %}
                          {{ authenticationform|crispy }}
                      &lt;/div&gt;
                      &lt;div class="modal-footer"&gt;
                          &lt;input type='submit' class="btn btn-primary" value="Log In" /&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Edit 2: register.html</strong></p>
  
  <pre><code>{% load staticfiles %}
  {% load crispy_forms_tags %}
  
  &lt;div class="modal" id="modal-register"&gt;
          &lt;div class="modal-dialog"&gt;
              &lt;div class="modal-content"&gt;
                  &lt;form enctype="multipart/form-data" method="post" action="register/"&gt;
                      &lt;div class="modal-header"&gt;
                          &lt;button type="button" class="close" data-dismiss="modal"&gt;&amp;times;&lt;/button&gt;
                          &lt;h3 class="modal-title"&gt;Register&lt;/h3&gt;
                      &lt;/div&gt;
                      &lt;div class="modal-body"&gt;
                          {% csrf_token %}
                          {{ registrationform|crispy }}
                      &lt;/div&gt;
                      &lt;div class="modal-footer"&gt;
                          &lt;input type='submit' class="btn btn-primary" value="Register" /&gt;
                      &lt;/div&gt;
                  &lt;/form&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>