2
respostas

Programamação Python

Alguém poderia me dizer o que está o errado no seguinte código Quando tiro o valor do Href ele funciona, mais quando coloco da o seguinte erro

NoReverseMatch at / Reverse for 'blog.views.post_detail' with arguments '()' and keyword arguments '{'pk': 2}' not found. 0 pattern(s) tried: [] Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 1.10.2 Exception Type: NoReverseMatch Exception Value:Reverse for 'blog.views.post_detail' with arguments '()' and keyword arguments '{'pk': 2}' not found. 0 pattern(s) tried: [] Exception Location: C:\Python35\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 392 Python Executable: C:\Python35\python.exe Python Version: 3.5.2 Python Path:['C:\Users\2T_ADMIN-PC\Documents\Projeto_py\mysite', 'C:\Python35\python35.zip', 'C:\Python35\DLLs', 'C:\Python35\lib', 'C:\Python35', 'C:\Python35\lib\site-packages'] Server time: Sab, 29 Out 2016 22:47:31 -0300

código

{% extends 'blog/base.html' %}

{% block content %} {% for post in posts %}

{{ post.published_date }}

{{ post.title }}

{{ post.text|linebreaksbr }}

{% endfor %} {% endblock content %}
2 respostas

Tacio, edita teu postado e coloca o código e o erro formatado. É só clicar em inserir código e colocar lá dentro onde tiver

insira seu código aqui
<h1><a href="{% url 'blog.views.post_detail' pk=post.pk %}">{{ post.title }}</a></h1>

Quando coloco esse valor no j=href da os seguinte erro:

NoReverseMatch at / Reverse for 'blog.views.post_detail' with arguments '()' and keyword arguments '{'pk': 2}' not found. 0 pattern(s) tried: [] Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 1.10.2 Exception Type: NoReverseMatch Exception Value:Reverse for 'blog.views.post_detail' with arguments '()' and keyword arguments '{'pk': 2}' not found. 0 pattern(s) tried: [] Exception Location: C:\Python35\lib\site-packages\django\urls\resolvers.py in _reverse_with_prefix, line 392 Python Executable: C:\Python35\python.exe Python Version: 3.5.2 Python Path:['C:\Users\2T_ADMIN-PC\Documents\Projeto_py\mysite', 'C:\Python35\python35.zip', 'C:\Python35\DLLs', 'C:\Python35\lib', 'C:\Python35', 'C:\Python35\lib\site-packages'] Server time: Sab, 29 Out 2016 22:47:31 -0300

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software