python - Using request.META.get('HTTP_REFERER') in URL reverse in Django -


i have form in template , when form submitted i'm trying redirect url form along arguments

here how i'm doing it

if request.method == 'post':     ...     url = reverse(request.meta.get('http_referer', '/'), kwargs={'groups': groups, 'product': product})     return httpresponseredirect(url) 

this gives me error

u'http' not registered namespace 

how can this?

reverse expects view name.

either , lose of arguments unless build them form of string interpolation

url = "{0}/{1}".format(request.meta.get('http_referer', '/'), your_args)  return httpresponseredirect(url) 

or decide view you're trying redirect redirects same place ie.

url = reverse('form_landing_view', kwargs={'groups':groups, 'product': product}) 

the third option using resolve().


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -