title: Build error with variables and url_for in Flask
body: <p>Have found one or two people on the interwebs with similar problems, but haven't seen a solution posted anywhere. I'm getting a build error from the code/template below, but can't figure out where the issue is or why it's occurring. It appears that the template isn't recognizing the function, but don't know why this would be occurring. Any help would be greatly appreciated - have been pounding my against the keyboard for two nights now. </p>
  
  <p>Function:</p>
  
  <pre><code>@app.route('/viewproj/&lt;proj&gt;', methods=['GET','POST'])
  def viewproj(proj):
  </code></pre>
  
  <p>...</p>
  
  <p>Template Excerpt:</p>
  
  <pre><code>{% for project in projects %}
    &lt;li&gt;
  &lt;a href="{{ url_for('viewproj', proj=project.project_name) }}"&gt;
  {{project.project_name}}&lt;/a&gt;&lt;/li&gt;
  {% else %}
  No projects
  {% endfor %}
  </code></pre>
  
  <p>Error log: 
  <a href="https://gist.github.com/1684250" rel="noreferrer">https://gist.github.com/1684250</a></p>
  
  <p>EDIT: Also wanted to include that it's not recognizing the variable "proj" when building the URL, so it's just appending the value as a parameter. Here's an example:
  //myproject/viewproj?projname=what+up</p>
  
  <p>Last few lines:</p>
  
  <pre><code>[Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128]   File "/srv/www/myproject.com/myproject/templates/layout.html", line 103, in top-level template code, referer: xx://myproject.com/
  [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128]     {% block body %}{% endblock %}, referer: xx://myproject.com/
  [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128]   File "/srv/www/myproject.com/myproject/templates/main.html", line 34, in block "body", referer: xx://myproject.com/
  [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128]     &lt;a href="{{ url_for('viewproj', proj=project.project_name) }}"&gt;, referer: xx://myproject.com/
  [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128]   File "/usr/lib/python2.7/dist-packages/flask/helpers.py", line 195, in url_for, referer: xx://myproject.com/
  [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128]     return ctx.url_adapter.build(endpoint, values, force_external=external), referer: xx://myproject.com/
  [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128]   File "/usr/lib/pymodules/python2.7/werkzeug/routing.py", line 1409, in build, referer: xx://myproject.com/
  [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128]     raise BuildError(endpoint, values, method), referer: xx://myproject.com/
  [Wed Jan 25 09:47:34 2012] [error] [client 199.58.143.128] BuildError: ('viewproj', {'proj': '12th'}, None), referer: xx://myproject.com/
  </code></pre>