1

I am trying to use request.env.http_referer but it seems I am missing something.

This is what I tried in the View:

{{if request.env.http_referer != 'http://127.0.0.1:8000/test_wp/default/show_test/1':}}
<h1>Something</h1>
{{pass}}

This works but depending on the args, the URL will have a different ending. How can I make this work with any number at the and of the URL after the show_test?

Joe T. Boka
  • 6,554
  • 6
  • 29
  • 48

1 Answers1

2
{{if not request.env.http_referer.startswith(
      'http://127.0.0.1:8000/test_wp/default/show_test/'):}}

For more sophisticated pattern matching, you can of course use regular expressions.

Anthony
  • 25,466
  • 3
  • 28
  • 57
  • Thanks very much. I should have thought of that. – Joe T. Boka May 20 '15 at 01:48
  • Anthony, I wonder if you can help me with on other problem which I can't solve for a while now. This is the question:http://stackoverflow.com/questions/30162866/how-to-change-the-background-image-using-img-file-from-database-in-web2py/30213309#30213309 – Joe T. Boka May 25 '15 at 11:55