get query param in django
To get a query parameter in Django, follow these steps:
- Import the required module:
from django.http import QueryDict
- Access the request object in your view:
def your_view(request):
- Get the QueryDict object from the request:
query_params = request.GET
- Access the specific parameter using the
get()
method:
param_value = query_params.get('your_param_name')
Here's the complete code snippet:
from django.http import QueryDict
def your_view(request):
query_params = request.GET
param_value = query_params.get('your_param_name')
# Use param_value as needed in your view logic
Replace 'your_param_name'
with the actual name of the query parameter you want to retrieve.