Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
Django QueryDict ¿Cómo asegurarse de que el "más" no desaparezca en el QueryDict?

¿Cómo asegurarse de que el "más" no desaparezca en el QueryDict?

Estoy tratando de analizar la consulta de obtención recibida en un dictado:

 from urllib.parse import quote_plus my_non_safe_string = "test=1+1" # This example, the string can be anything. (in GET query format) QueryDict(my_non_safe_string) out: <QueryDict: {'test': ['1 1']}> my_safe_string = quote_plus("test=1+1") # 'test%3D1%2B1' out: <QueryDict: {'test=1+1': ['']}>

Me gustaría obtener el siguiente resultado:

 <QueryDict: {'test=1+1': ['1+1']}>
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Debe codificar en porcentaje el signo más, al usar quote_plus también codifica el signo igual ( = ) y, por lo tanto, QueryDict no puede analizarlo de manera efectiva:

 my_safe_string = f'test={quote_plus("1+1")}'

esto produce:

 >>> from urllib.parse import quote_plus >>> my_safe_string = f'test={quote_plus("1+1")}' >>> QueryDict(my_safe_string) <QueryDict: {'test': ['1+1']}>

Si no está claro si la clave contiene algún carácter que deba escaparse, puede usar:

 key = 'test' value = '1+1' my_safe_string = f'{ quote_plus(key) }={ quote_plus(value) }'
over 4 years ago · Santiago Trujillo Report

0

¿Qué tal esto?

 In [1]: from django.http import QueryDict In [2]: from urllib.parse import quote_plus In [3]: key = quote_plus("test=1+1") In [4]: value = quote_plus("1+1") In [5]: query_str = f"{key}={value}" In [6]: QueryDict(query_str) Out[6]: <QueryDict: {'test=1+1': ['1+1']}>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!