title: Django: TemplateSyntaxError, Invalid filter
body: <p>I'm trying to access a value from a dictionary using a variable, all in an HTML file that follows Django's Templating language. Django's templating language doesn't let you access a dictionary using a variable as a key, so I decided to use Django filters to do it. However, I am getting a "Invalid filter" error and I can't figure out why.</p>
  
  <p>My html file</p>
  
  <pre><code>&lt;table class="table"&gt;
  &lt;tbody&gt;
      &lt;tr&gt;
          &lt;th scope="row"&gt;Username&lt;/th&gt;
          &lt;th scope="row"&gt;Full Name&lt;/th&gt;
          &lt;th scope="row"&gt;Points&lt;/th&gt;
          {% for subject in subjects %}
          &lt;th scope="row"&gt;{{ subject }}&lt;/th&gt;
          {% endfor %}
      &lt;/tr&gt;
      {% for user in users %}
      &lt;tr&gt;
          &lt;td&gt;
              &lt;a href="{% url 'profile' username=user.username %}"&gt;{{ user.username }}&lt;/a&gt;
          &lt;/td&gt;
          &lt;td&gt;{{ user.first_name }} {{ user.last_name }}&lt;/td&gt;
          &lt;td&gt;{{ user.profile.points.total }}&lt;/td&gt;
          {% for subject in subjects %}
          &lt;td&gt;{{ user.profile.points|keyvalue:subject }}&lt;/td&gt;
          {% endfor %}
      &lt;/tr&gt;
      {% endfor %}
  &lt;/tbody&gt;
  </code></pre>
  
  <p></p>
  
  <p>My filter.py</p>
  
  <pre><code>from django import template
  register = template.Library()
  
  @register.filter
  def keyvalue(dict, key):    
      return dict[key]
  </code></pre>
  
  <p>My error message</p>
  
  <pre><code>TemplateSyntaxError at /leaderboard/
  Invalid filter: 'keyvalue'
  </code></pre>
  
  <p>Thank you for any help :D</p>
  
  <p>EDIT: Pasting my views.py and urls.pu as requested</p>
  
  <p>views.py<br></p>
  
  <pre><code>def leaderboard(request):
      global leaderboard_public
      users = sorted(User.objects.all(), key=lambda t: t.profile.points['total'], reverse=True)
  
      if request.method == "POST":
          leaderboard_public = not leaderboard_public
          return redirect(leaderboard)
      subjects = list(Subject.objects.values('subject_name'))
      subjects = [i['subject_name'] for i in subjects]
      print(subjects)
      return render(request, "leaderboard.html", {
          "users": users,
          "subjects": subjects,
          # "leaderboard_public": leaderboard_public,
      })
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>from accounts import views as accountsViews
  from puzzles import views as puzzlesViews
  
  urlpatterns = [
  url(r'^admin/', admin.site.urls),
  
  url(r'^signup/$', accountsViews.signup_without_email, name="signup"),
  url(r'^activate/(?P&lt;uidb64&gt;[0-9A-Za-z_\-]+)/(?P&lt;token&gt;[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
      accountsViews.activate, name='activate'),
  url(r'^logout/$', authViews.LogoutView.as_view(), name='logout'),
  url(r'^login/$', authViews.LoginView.as_view(template_name='login.html'), name="login"),
  # url(r'^puzzles/$', puzzlesViews.puzzles, name="puzzles"),
  url(r'^puzzle/(?P&lt;puzzleID&gt;.+)/edit/$', puzzlesViews.editPuzzle, name="editPuzzle"),
  url(r'^puzzle/(?P&lt;puzzleID&gt;.+)/$', puzzlesViews.puzzle, name="puzzle"),
  url(r'^scheduled/$', puzzlesViews.scheduled, name="scheduled"),
  url(r'^closed/$', puzzlesViews.closed, name="closed"),
  url(r'^leaderboard/$', accountsViews.leaderboard, name="leaderboard"),
  # url(r'^leaderboard/(?P&lt;subject&gt;.+)/$', accountsViews.leaderboard_subject, name="leaderboard"),
  # url(r'^submissions/$', puzzlesViews.submissions, name="submissions"),
  url(r'^profile/(?P&lt;username&gt;.+)/submissions$', puzzlesViews.submissions, name="submissions"),
  url(r'^profile/(?P&lt;username&gt;.+)/edit/$', accountsViews.editProfile, name="editProfile"),
  url(r'^profile/(?P&lt;username&gt;.+)/$', accountsViews.profile, name="profile"),
  url(r'^create/$', puzzlesViews.create, name="create"),
  # url(r'^$', views.home, name="home"),
  url(r'^$', puzzlesViews.puzzles, name="puzzles"),
  ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
  </code></pre>
  
  <p>Let me know if there's any other information needed.</p>