Reputation: 2546
I have the following urlpattern:
url(r'exp/users/(?P<userid>\w.+)/$', 'myapp.views.users_view_by_id', name='users_id'),
When userid is a single digit (eg '1') I get a 404 Page Not Found but when it is more than a single digit the page responds as expected (eg '10').
So '../exp/users/10/'
works fine but '.../exp/users/1/'
returns a 404.
Upvotes: 2
Views: 298
Reputation: 599450
You have an extra .
in your regex.
\w.+
means "one alphanumeric character, then one or more of any character". What you want is just \w+
, which means "one or more alphanumeric characters".
Edit
If you want to include a literal "." in the characters that can be accepted, use square brackets to define a class:
(?P<userid>[\w.]+)
Upvotes: 3
Reputation: 308769
If you want to match one or more digits, then use (?P<userid>\d+)
.
Your current regex requires one character to match \w
', followed by at least one character to match .+
.
Upvotes: 0