#37155: Allow templatetag `querystring` to start from an empty state
-------------------------------------+-------------------------------------
     Reporter:  Sjoerd Job Postmus   |                     Type:  New
                                     |  feature
       Status:  new                  |                Component:  Template
                                     |  system
      Version:  6.0                  |                 Severity:  Normal
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 The documentation for `querystring` starts with

 > Outputs a URL-encoded formatted query string based on the provided
 parameters.

 But the current functionality is mostly limited to taking an existing
 mapping; modifying that in-place, and *then* rendering that as a
 querystring. (it defaults to `request.GET` if no mapping is provided).

 When constructing an update for the querystring of the current view; this
 feels natural. When constructing the querystring of a different view
 (e.g.: a detail page where an attribute is rendered as a clickable link to
 some list filtered by that value), the current querystring is not
 relevant.

 Use-case:

 Instead of writing

 {{{
     <a href="{% url 'product_list' %}?vendor={{ vendor.pk|unlocalize}}">{{
 vendor.name }}</a>
 }}}

 I would like to be able to write

 {{{
     <a href="{% url 'product_list' %}{% querystring None vendor=vendor.pk
 %}">{{ vendor.name }}</a>
 }}}

 (Note; the savings will be a lot better if there is more than 1
 querystring parameter)

 The change to the `querystring` would be reasonable minimal; and it would
 unlock an easier way of writing querystrings in more scenarios than
 currently available.

 A workaround may be to create an empty dictionary, and provide that either
 via the context or a contextprocessor; but I feel that's less natural than
 just being able to write 'None' for starting with an empty dictionary.

 If accepted; I would be happy to pick up the development.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/37155>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/0107019eb0bf8e1d-216884fc-f299-4d7c-9e44-74683cf1db22-000000%40eu-central-1.amazonses.com.

Reply via email to