title: Where in my django app do I implement this get_client_ip() function?
body: <p>I have a Custom User model that takes user ip address. <strong>I want to add the IP address of the user upon completion of the sign up form</strong>. <strong>Where do I implement the below code?</strong> I am not sure whether to put this into my forms.py or views.py file.</p>
  
  <pre><code>def get_client_ip(request):
      x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
      if x_forwarded_for:
          ip = x_forwarded_for.split(',')[0]
      else:
          ip = request.META.get('REMOTE_ADDR')
      return ip
  </code></pre>
  
  <p>I expect to be able to save the user's ip address into my custom user table upon sign up.</p>