#30310: New HTTPRequest.headers not usable in templates because of hyphens
-------------------------------------+-------------------------------------
Reporter: Mark | Owner: nobody
Tranchant |
Type: Bug | Status: new
Component: Template | Version: 2.2
system | Keywords: request headers
Severity: Normal | hyphen template
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
With the release of 2.2, I took the opportunity from the new
[https://docs.djangoproject.com/en/2.2/ref/request-
response/#django.http.HttpRequest.headers HTTPRequest.headers object] to
clean up old code using e.g. `request.META['HTTP_X_REAL_IP']` to
`request.headers['X-Real-IP']`.
However, this new approach does not work with templates, as
[https://docs.djangoproject.com/en/2.2/ref/templates/api/#variables-and-
lookups variable lookups cannot use hyphens].
Could the object contain a parallel set of keys in underscored variables?
e.g. `request.headers['foo-bar']` is also available in
`request.headers['foo_bar']` and can be looked up with `{{
request.headers.foo_bar }}` in a template?
--
Ticket URL: <https://code.djangoproject.com/ticket/30310>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.74df795a2f4d4fad1f6f442039f55db4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.