title: Django Class Based View, set request.session to some value as soon as user lands on a page
body: <p>I have the following need:</p>
  
  <p>I have some sports-betting data on my website and I need to display it in different formats according to user's location.
  I am talking about odds format, something like this (it's the same value):
  decimal: 2.00 (for Europeans)
  american: +100 (for Americans)</p>
  
  <p>I have implemented a function that is something like this and works well:</p>
  
  <pre class="lang-py prettyprint-override"><code>def check_ip_and_set_initial_odds_format(request):
      country = get_country(get_client_ip2(request))['country_name']
      if country == 'United States' and 'odds_format' not in request.session:
          request.session['odds_format'] = 'American'
      return request.session
  </code></pre>
  
  <p>So basically, the idea is that if a user visits my website for the first time, the odds_format gets set automatically and the website already provides the right odds format.</p>
  
  <p>My question is: Can I implement this so that no matter which page the user interacts with for the first time, the odds_format gets set to the right value? For now I have implemented it on the home page, but if someone ends up on my website on a different page, odds would not display correctly.</p>
  
  <p>I know I could just call the function in all my views, but I was thinking of something more clever, like editing the View base class maybe?
  If this is the right approach, how would I achieve that?</p>
  
  <p>Thanks!</p>