How to read question mark in the URL of django framework?

I am developing a Django app that stores the user input in the database. Now the problem is that when the user writes the ? in the input field, Django treats it as the part of querystring so it doesn’t save it.

here is my urls.py file:

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

in views.py , I have:

def add(request,text):
    field = Text(text=text)
    field.save()
    return HttpResponse('')

the JavaScript code:

$("#submit").on("click",function(){
    text = $("#input").val();
    $.get('/add/'+text);
}

The problem isn’t Django. A normal form submission will encode such
characters, even a GET form. The problem is your JavaScript:

$("#submit").on("click",function(){
    text = $("#input").val();
    $.get('/add/'+text);
}

That is the wrong way to pass text. There’ll be a correct way to pass
text as the query string contents. You’re just wacking it onto the end
of the URL, which is wrong.

My JavaScript is pretty rusty. Look up how to do form submissions with
the toolkit you’re using.

Cheers,
Cameron Simpson cs@cskk.id.au