django-query-params
Django app providing template tags and JavaScript functions for query string management.
Template Tag Library
To install the app, type:
(venv)$ pip install django-query-params
Then add "query_params" to the INSTALLED_APPS in the settings.
To use the template tags in templates:
{% load query_params_tags %}
{% modify_query ["only_query_string"] "param_to_remove" "another_param_to_remove" param_to_change="new-value" another_param_to_change="new-value" %}
{% add_to_query ["only_query_string"] "param_to_remove" "another_param_to_remove" param_to_add="new-value" another_param_to_add="new-value" %}
{% remove_from_query ["only_query_string"] "param_to_remove" another_param_to_remove="value" %}
JavaScript Library
{% load static %}
<script src="{% static 'query_params/js/query_params.js' %}"></script>
<script>
var url1 = modify_query(
location,
['param_to_remove', 'another_param_to_remove'],
{
param_to_change: 'new-value',
another_param_to_change: 'new-value'
},
only_query_string=false
);
var url2 = add_to_query(
location,
['param_to_remove', 'another_param_to_remove'],
{
param_to_add: 'new-value',
another_param_to_add: 'new-value'
},
only_query_string=false
);
var url3 = remove_from_query(
location,
['param_to_remove'],
{
another_param_to_remove: 'value'
},
only_query_string=false
);
</script>
Example
Let's say the current URL is:
https://example.com/posts/?page=2&sort=by-date&tag=environment&tag=sustainability
modify_query
{% modify_query "page" tag="ecological" %}
will render:
/posts/?sort=by-date&tag=ecological
and
{% modify_query "only_query_string" "page" tag="ecological" %}
will render:
?sort=by-date&tag=ecological
add_to_query
{% add_to_query "page" tag="ecological" %}
will render:
/posts/?sort=by-date&tag=ecological&tag=environment&tag=sustainability
and
{% add_to_query "only_query_string" "page" tag="ecological" %}
will render:
?sort=by-date&tag=ecological&tag=environment&tag=sustainability
remove_from_query
{% remove_from_query "page" tag="environment" %}
will render:
/posts/?sort=by-date&tag=sustainability
and
{% remove_from_query "only_query_string" "page" tag="environment" %}
will render:
?sort=by-date&tag=sustainability
Metadata
Release files for django-query-params 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-query-params-1.0.0.tar.gz | 6.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_query_params-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.3 kB
Release files / django-query-params-1.0.0.tar.gz
| Download URL | django-query-params-1.0.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e6cc1293c9c8be0ac4869e9e1c5bc6d5ef090e7ce94cfbbc3697ca67f399aa8
|
|
BLAKE2b-256 checksum How to use checksums |
ca1140751be221083ed3021e1192ba9dbf318c410a5bc530fda59e2106c85b7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Release files / django_query_params-1.0.0-py3-none-any.whl
| Download URL | django_query_params-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e672761d68356943bdf805d063e5ccc7886b438402c293b911aca0ff7df2a13f
|
|
BLAKE2b-256 checksum How to use checksums |
0494ff2f6233e4d6904be6c5e924e5c5ad62ea45401f1fa98401377abd44a45d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.0
|
Security for django-query-params 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.