title: Recommended way of talking to a Django application URL, from within a view of the same application?
body: <p>I have a Django application, and need to deal with the following:</p>
  
  <ul>
  <li>One of my views, needs to make a POST request to another URL endpoint of the same application.</li>
  <li>In order to do so, I use the <code>requests</code> module. I assemble the URL of the endpoint I need to call, dump the POST parameters, and perform the call.</li>
  <li>This works fine for the most part, however fails miserably when testing, since the view that corresponds to the URL that I talk to, knows nothing about the state of the testing environment.</li>
  </ul>
  
  <p>The code is similar to this:</p>
  
  <pre><code>from django.conf import settings
  import json
  def view1(request, *args, **kwargs):
      url = 'http://api.%s/view2/' % settings.DOMAIN      
      r = requests.post(
          url,
          data=json.dumps({'key': 'value'}),
      )      
      // Notice that the ``url`` is a url of the actual deployed application, 
      // and therefore knows nothing about testing and its state. That's where 
      // it goes wrong.
  </code></pre>
  
  <p>The question is, is there a way that this can behave correctly in testing? I use the <code>django.test.client.Client</code> class for creating my test requests. As far as I know, instances of this class talk directly to the URL mapper. Therefore the <code>url</code> that I construct in the view is simply an external http request to the deployed application, instead of the <strong>tested</strong> application.</p>
  
  <p>Thanks.</p>