1

これが を返すのはなぜNoReverseMatchですか?

django-postmanから:

url(r'^write/(?:(?P<recipients>[\w.@+-:]+)/)?$', 'write', name='postman_write'),

テンプレート:

<a href='{% url postman_write recipients=object.user %}'>Send Message</a>

これもうまくいきません..

<a href='{% url postman_write object.user %}'>Send Message</a>

戻り値:Reverse for 'postman_write' with arguments '(<User: admin>,)' and keyword arguments '{}' not found.この URL を適切に構築するために不足しているものは何ですか? ありがとう!

4

2 に答える 2

0

試す:

{% url postman_write object.user.username %}

于 2013-01-24T08:53:25.487 に答える
0

urlタグでユーザーオブジェクトを渡しています。ユーザー名を渡す必要があります。

{% url postman_write recipients=object.user.username %}

urls.pyまた、メインファイルに郵便配達員の URL が含まれていることを確認してください。

于 2013-01-23T19:52:16.570 に答える