NoReverseMatch at /natrium/script/4c55be7f74312bfd435e4f672e83f44374a046a6aa08729aad6b0b1ab84a8274/
Reverse for 'run_details' with arguments '()' and keyword arguments '{'script_text': u'print "happy"', 'run_id': '6b2f9127071968c099673254fb3efbaf'}' not found.
これは抜粋リダイレクト時に、非URL定義ビューのキーワードをビュー関数に渡すことはできますか?
def run_details(request, run_id, script_text):
"""
Displays the details of a given run.
"""
run = Run(run_id)
run.update(request.user)
codebundle = CodeBundle(run.cbid)
codebundle.update(request.user)
return render_response(request, "graphyte/runs/run_script.html",
{'run':run, 'codebundle':codebundle, 'files':run.artifacts, 'bundle':codebundle,
'source_code': script_text
})
このビュー関数を呼び出す順番に今これは私のurls.py.ある私のviews.pyの
run_id = new_run.run_id
if not run_id:
raise AssertionError("bad run id")
# I tried with args=[run_id, clean['script_text']] too
return HttpResponseRedirect(reverse('run_details', kwargs={'run_id':run_id, 'script_text':clean['script_text']}))
です実際のリダイレクトビューは別のアプリにあります(ちょっと気違いですが...)。
urlpatterns = patterns("webclient.apps.codebundles.views",
# many.....
url(r"^cb/newfolder/$", 'codebundle_newfolder', name="codebundle_newfolder"),
)
urlpatterns += patterns('webclient.apps.runs.views',
url(r"^run_details/(?P<run_id>\w+)/$", 'run_details', name="run_details"),)
これは、過去3時間では本当に厄介なものになっています。私は何が起こっているのか分かりません。誰かがこれをデバッグする手助けができますか?
ありがとうございました。
元のプランはscript_textを持たず、args = ['run_id']のみを使用しました。できます。言い換えると、すべてが動く2つのビューからscript_textを削除します。混乱させて申し訳ありません
EDIT 。スクリプトのテキストは、逆の送り先に渡す必要のあるコンテキスト変数であり、そこからテンプレートをレンダリングします。 URLにはrun_idのみが表示されます。
詳細をご覧いただきありがとうございます。 script_textはソースコードの文字列なので、URLに入れるのは面倒なことではありません。セッションは回避策になるかもしれません(gloablと同等です変数、これは今私がテストに使っているものです)。 – CppLearner