Django parameter stops printing when it reaches the first question mark symbol

47 Views Asked by At

I have been learning the weird set-ups of Django! Its very good for web development!

I have the following view inside views.py:

def callerview(request,paramm):
  text="this is what was sent : %s"%paramm
   return HttpResponse(text)

the url for this this view at urls.py is as follows:

urlpatterns = [
path('callerview/<str:paramm>/', views.callerview, name='callerview'),
]

Now, I am sending a word problem to it as the 'paramm'. It works and prints the word problem at localhost. But if the word problem has a question mark it stops printing when it gets to the first ? .

so if the url looks like: callerview/why are roses red? why is the sky blue? Then, in the localhost output i will get: why are roses red AND no more!

I need to be able to get all the symbols and letters in the word problem! in order to send to OpenAi assistants API.

Any advice on how I can keep the ? symbol in the printout of the word problem?

1

There are 1 best solutions below

3
Chukwujiobi Canon On

The question mark is reserved in HTTP URLs. [RFC 1738] It represents the start of query parameters in HTTP URLs.

In your case, the URL parameter ends where the symbol ? is found and the query parameters begin from there. Django simply follows the URL specification.