# didn’t match any of these.

**URL:** <https://forum.djangoproject.com/t/didn-t-match-any-of-these/10293>\
**Category:** Using Django\
**Created:** [October 28, 2021, 5:19pm UTC](https://forum.djangoproject.com/t/didn-t-match-any-of-these/10293 "2021-10-28T17:19:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MeghvShetty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/meghvshetty/32/6212_2.png) [@MeghvShetty](https://forum.djangoproject.com/u/MeghvShetty)\
**Post date:** [October 28, 2021, 5:19pm UTC](https://forum.djangoproject.com/t/didn-t-match-any-of-these/10293/1 "2021-10-28T17:19:42Z")

</div>

Hello Guys,  
I am developing a blogsite using django and i am new to django. I am getting an error

```auto
The current path, blog/{ % url 'article/'Post.pk %}, didn’t match any of these. 

```

my url.py

```auto
from django.urls import path
#from . import views 
from . views import PostView, ArticleView

urlpatterns = [
    #path('',views.blog,name="blog"),
    path('',PostView.as_view(),name='post'), # class based view url
    path('article/<int:pk>',name='article'),
    #path('',PostView.as_view()),
]

```

my blog.html

```auto
<h1>Welcome to the blog site</h1>
<ul>
{% for Post in object_list %}
   <li>
       <a href="{ % url 'article/'Post.pk %}">{{Post.post_title}} </a> - 
       {{Post.post_author}} </br>
    {{Post.post_body}} {{Post.pk}}</li>
{% endfor %} </ul>

```

my View.py

```auto
from django.shortcuts import render
from django.views.generic import ListView, DetailView
from .models import Post
#from blog import models
# Create your views here.
#def blog(request):
# return render(request,'blog.html',{})

class PostView(ListView):
    model= Post
    template_name='blog.html'
    

class ArticleView(DetailView):
    model = Post
    template_name = 'articles_details.html'

```

I am not able find what i am missing? Thank you for the help !!

---

<div class="post-metadata">

**Author:** ![Rigo-Villalta](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/rigo-villalta/32/5667_2.png) [@Rigo-Villalta](https://forum.djangoproject.com/u/Rigo-Villalta)\
**Post date:** [October 28, 2021, 5:39pm UTC](https://forum.djangoproject.com/t/didn-t-match-any-of-these/10293/2 "2021-10-28T17:39:39Z")

</div>

You are using the named path syntax and the “url” template tag, so your template tag must be like this:

```auto
<a href="{ % url 'article' Post.pk %}">{{ Post.post_title }} </a>

```

This is because with the “url” template tag you aren’t telling to Django that you will form a string, for example your path could be like this

```auto
path('anythingelse/<int:pk>',name='article'),

```

And eve so the syntax above should work because your are referring the “name” property of the path, not the path it self. This is the other way (hardconding the url):

```auto
<a href="/article/{{ Post.pk }}">{{ Post.post_title }} </a>

```

In the last case you are building the url with a variable, the problem with that approach is that could be difficult to change and maintenance. Read [this part](https://docs.djangoproject.com/en/3.2/intro/tutorial03/#removing-hardcoded-urls-in-templates) of the Django Tutorial as reference.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [October 28, 2021, 7:47pm UTC](https://forum.djangoproject.com/t/didn-t-match-any-of-these/10293/3 "2021-10-28T19:47:15Z")

</div>

Couple different things wrong here.

> [@MeghvShetty](#):
>
> ` <a href="{ % url 'article/'Post.pk %}">{{Post.post_title}} </a> -`

The problem in your template here is that you have a space between the `{` and the `%`, and you’re missing a space between the url name and the url parameter. It should read something like:  
`<a href="{% url 'article' Post.pk %}">{{Post.post_title}} </a>`  
No space between the `{` and `%`, and a space between the url name (which is “article”, _not_ “article/”) and the parameter `Post.pk`.

You might want to review [the docs on the url tag](https://docs.djangoproject.com/en/3.2/ref/templates/builtins/#url).

---

<div class="post-metadata">

**Author:** ![MeghvShetty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/meghvshetty/32/6212_2.png) [@MeghvShetty](https://forum.djangoproject.com/u/MeghvShetty)\
**Post date:** [October 29, 2021, 7:35am UTC](https://forum.djangoproject.com/t/didn-t-match-any-of-these/10293/4 "2021-10-29T07:35:01Z")

</div>

Thank you for the answer!!

---

<div class="post-metadata">

**Author:** ![MeghvShetty](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/meghvshetty/32/6212_2.png) [@MeghvShetty](https://forum.djangoproject.com/u/MeghvShetty)\
**Post date:** [October 29, 2021, 7:38am UTC](https://forum.djangoproject.com/t/didn-t-match-any-of-these/10293/5 "2021-10-29T07:38:15Z")

</div>

Thank you for the answer!! I will do the following
