[Fixed]-Django Error: Reverse for 'blog_detail_url' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: ['blog/(?P<id>\\d+)$']

1👍

Change your links from

"{% url 'blog:blog_detail_url' Next_Post.id %}"

to

"{% url 'blog:blog_detail_url' id=Next_Post.id %}"

Notice the id=. Your url pattern specifies id as a url kwarg.

Also, as a rule of thumb, you should not name your variables with upper-case letters. In Python, it’s standard to use lower-case variable names, and then have upper case names for classes. When this is done consistently, it helps make your code more readable.

EDIT

This also seems a little fishy to me: {% if Next_Post is defined and Previous_Post is defined %} what is defined ? I don’t see it in the context or anywhere else. I would do this:

{% if next_post %}
    {# ... #}
{% endif %}

Leave a comment