-1

I'm trying to generate a regex for just numbers. But for some reason the pattern doesn't seem to match. My code is:

url('^[\d\-]+/$', views.room, name='room'),

The request has to go to this expression. The HTML href for the above is:

<href="/polls/layout/103/>
1

1 Answer 1

2

I'm assuming polls/ is caught upstream in the project urls.py and you're editing the app urls.py. You need to catch 'layout/' as well as '103'.

url('^layout/[0-9]+/$', views.room, name='room'),

If you need to capture the '103' for further processing within the view (likely), you might want to try something like:

url('^layout/(?P<room_number>[0-9]+)/$', views.room, name='room'),

where 'room_number' is an arg to the room class in your app's views.py.

Sign up to request clarification or add additional context in comments.

1 Comment

Damn I forgot to add, I solved the problem. Silly mistake of mine. But yes. Thanks for the solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.