0

I have an url like -

...poll/3/what's-up?

In urlpatterns, I am checking for any kind of string for question text with following code -

url(r'^poll/(?P<question_id>[0-9])/(?P<question_text>.+)', views.question_details),

After debugging i see it returns in view -

question_text = what's-up

but not

question_text = what's-up?

I think this is my regex implementation issue.

user3384985
  • 2,975
  • 6
  • 26
  • 42
  • The elements after the `?` are not part of the url, [see here](http://stackoverflow.com/a/12079541/5288316). – Nicolas Nov 12 '16 at 16:14
  • yes, query parameters are executed after `?`. What I have tried to verify the question text with record. I think I have to skip `?` in both url `request.GET` and record text. – user3384985 Nov 12 '16 at 16:25

1 Answers1

0

Try to escape ? in your Regex, and see if that helps:

url(r'^poll/(?P<question_id>[0-9])/(?P<question_text>.+\??)', views.question_details),
Ibrahim
  • 6,006
  • 3
  • 39
  • 50