Pergunta

Why does this return a NoReverseMatch?

From django-postman:

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

Template:

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

This does not work either..

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

Returns: Reverse for 'postman_write' with arguments '(<User: admin>,)' and keyword arguments '{}' not found. What am I missing to construct this url properly? Thanks!

Foi útil?

Solução

you are passing a user object in url tag. You need to pass the username.

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

Also make sure you have included the postman urls in your main urls.py file.

Outras dicas

Try:

{% url postman_write object.user.username %}

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top