0

私のコードでは、Jinja2 テンプレートからフラスコに 2 つの変数を渡そうとしています。これまでのところ、これは私がやったことです:

<th><a href="{{ url_for('admin.edit', title=post.title ,url=prop.url) }}">{{ post.url }}    </a></th>

私のフラスコビューでは、getメソッドに到達する前にエラーが発生します:

 def get(self, title, url):
    print "geturl"

デバッガーから取得したエラーは、get() が正確に 3 つの非キーワード引数を取る (2 つ指定) です。

File "/Users/kimmy/Documents/Flask+MongoDB/flaskapp/lib/python2.6/site-packages/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/Users/kimmy/Documents/Flask+MongoDB/flaskapp/lib/python2.6/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/Users/kimmy/Documents/Flask+MongoDB/flaskapp/lib/python2.6/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/kimmy/Documents/Flask+MongoDB/flaskapp/lib/python2.6/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/Users/kimmy/Documents/Flask+MongoDB/flaskapp/lib/python2.6/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/kimmy/Documents/Flask+MongoDB/flaskapp/lib/python2.6/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/kimmy/Documents/Flask+MongoDB/flaskapp/lib/python2.6/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/kimmy/Documents/Flask+MongoDB/flaskapp/lib/python2.6/site-packages/flask_debugtoolbar/__init__.py", line 104, in dispatch_request
return view_func(**req.view_args)
File "/Users/kimmy/Documents/Flask+MongoDB/tumblelog/auth.py", line 26, in decorated
return f(*args, **kwargs)
File "/Users/kimmy/Documents/Flask+MongoDB/flaskapp/lib/python2.6/site-packages/flask/views.py", line 84, in view
return self.dispatch_request(*args, **kwargs)
File "/Users/kimmy/Documents/Flask+MongoDB/flaskapp/lib/python2.6/site-packages/flask/views.py", line 149, in dispatch_request
return meth(*args, **kwargs)
TypeError: get() takes exactly 3 non-keyword arguments (2 given)

私が使用しているテンプレートは次のとおりです。

{% extends "admin/base.html" %}
{% block content %}
  <table  class="condensed-table zebra-striped">
    <thead>
   <th>Title</th>
   <th>Url</th>
  <th>Date Added</th>
  <th>Actions</th>
</thead>
<tbody>

{% for post in posts %}
  <tr>


    <td>{{post.url}}</td>


    <th><a href="{{ url_for('admin.edit', title=post.title, url=post.url ) }}">{{ post.url }}</a></th>
    <td>{{ post.date_added}}</td>
    <!-- <td>{{ post.created_at.strftime('%Y-%m-%d') }}</td> -->
    <td><a href="{{ url_for("admin.edit", title=post.title , url=post.url ) }}" class="btn primary">Edit</a></td>
  </tr>
   {% endfor %}
{% endfor %}
</tbody>

4

0 に答える 0