[Answered ]-Regular expression Python Django url

2👍

You must be looking for

^articles/get/(?P<article_id>\d+)/$
                ^            ^^^^   

See the regex demo

The first issue is that you failed to use a named capture group correctly, and the second issue is that you did not capture anything by setting the closing ) right after the group name, while you want to capture 1+ digits with the \d+ into the article_id group.

Also, some reference on the named groups can be found here:

(?P<name>...)
Similar to regular parentheses, but the substring matched by the group is accessible via the symbolic group name name.

Leave a comment