Apetrei Alin
Apetrei Alin

Reputation: 19

Django matching URLs for simple titles

I'm trying to match an url in a django project. My urls are like this http://localhost:8000/article/Google-Home-Sales-Outpace-Amazons-Alexa-For-The-First-Time-13545 and in urls.py a have added:

path('article/(?P<article_title>[\w\d.\'%@+-]+)', views.article)

def article(request, article_title)):
    pass

but this doesn't work. Can anyone help me?

Upvotes: 0

Views: 35

Answers (1)

Andrew_Lvov
Andrew_Lvov

Reputation: 4668

Use re_path instead of path as shown in https://docs.djangoproject.com/en/2.0/topics/http/urls/

Upvotes: 1

Related Questions