title: " django.template.exceptions.TemplateSyntaxError: Invalid block tag on line 5: 'get_verbose_name', expected 'empty' or 'endfor'. "
body: <p>I have been searching for ways to display data from Django models in a view/template. I am still just a beginner but have read a lot of stackoverflow to gain knowledge. </p>
  
  <p>The implementation of what I am trying to do I picked up from this thread: <a href="https://stackoverflow.com/questions/14615847/display-table-of-objects-django">Display table of objects django</a></p>
  
  <p>After inputting the template.html and the views.py (slightly modifying my views.py - changing MyModel to the Environment Model) I am getting the error :</p>
  
  <p><code>"Invalid block tag on line 5: 'get_verbose_name', expected 'empty' or 'endfor'. Did you forget to register or load this tag?"</code></p>
  
  <p>This error is referring to the <code>&lt;th&gt;{% get_verbose_name field %}&lt;/th&gt;</code></p>
  
  <p>in template.html</p>
  
  <p>I have tried to add a verbose name to every field in the model but this is not the apparent issue. Attached in a pastebin is my views.py, models.py and template.html.</p>
  
  <p>My views.py and template.html are almost exactly the same as the solution checked in the linked stackoverflow thread. My issue is basically understanding why this error exists, and how I can resolve it</p>
  
  <p>Thank you for your help</p>
  
  <h1>tables.html</h1>
  
  <pre><code>&lt;table&gt;
  &lt;thead&gt;
      &lt;tr&gt;
          {% for field in cached_fields %}
              &lt;th&gt;{% get_verbose_name field %}&lt;/th&gt;
          {% endfor %}
      &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
          {% for d in data %}
              &lt;tr&gt;
                  {% for field in fields %}
                      &lt;td&gt;{% get_value_from_key d field %}&lt;/td&gt;
                  {% endfor %}
              &lt;/tr&gt;
          {% endfor %}
  &lt;/tbody&gt;
  </code></pre>
  
  <p></p>
  
  <h1>Views.py</h1>
  
  <pre><code>from __future__ import unicode_literals
  from django.views import generic
  from django.shortcuts import render, render_to_response, get_object_or_404,     redirect
  from django.contrib import messages
  from django.contrib.auth.mixins import LoginRequiredMixin
  from django.http import HttpRequest, HttpResponse
  from django.template import RequestContext
  import simplejson as json
  #from appDatabase.forms import *
  from . import forms;
  from . import models;
  
  class AppTable(generic.TemplateView):
      template_name = "appDatabase/tables.html"
  
  def index(request) :
      fields    = Environment._meta.fields
      data      = json.loads(serializers.serialize("json", Environment.objects.all()))
  
      def parse_data(data):
  
          result = []
  
          # flatten the dictionary
          def flatten_dict(d):
              """
              Because the only nested dict here is the fields, let's just
              remove the 'fields' suffix so that the fields can be loaded in
              template by name
              """
              def items():
                  for key, value in d.items():
                      if isinstance(value, dict):
                          for subkey, subvalue in flatten_dict(value).items():
                              yield subkey, subvalue
                      else:
                          yield key, value
  
              return dict(items())
          for d in data:
              # change the 'pk' key name into its actual name in the database
              d[Environment._meta.pk.name] = d.pop('pk')
              # append the flattend dict of each object's field-value to the result
              result.append(flatten_dict(d))
  
          return result
  
          context_instance  = RequestContext(request, {
          'data'      : parse_data(data),
          'fields'    : fields, })
      return TemplateResponse(request, 'tables.html', context_instance)
  </code></pre>
  
  <h1>Models.py</h1>
  
  <pre><code>from __future__ import unicode_literals
  from django.utils.encoding import python_2_unicode_compatible
  import uuid
  from django.contrib.auth.models import User
  from django.db import models
  from django import forms
  from django.forms import ModelForm;
  # Create your models here.
  
  
  class Environment(CommonInfo):
      environment_Type = models.CharField(verbose_name ="Environment Type", max_length=10)
      environment_Name = models.CharField(verbose_name ="Environment Name", max_length=10)
  </code></pre>