Is there a way to get the current page URL and all its parameters in a Django template?
For example, a templatetag that would print a full URL like /foo/bar?p
Use Django's build in context processor to get the request in template context. In settings add request processor to TEMPLATE_CONTEXT_PROCESSORS
TEMPLATE_CONTEXT_PROCESSORS = (
# Put your context processors here
'django.core.context_processors.request',
)
And in template use:
{{ request.get_full_path }}
This way you do not need to write any new code by yourself.