title: Django subdomain configuration for API endpoints
body: <p>I've set up a Django project which makes use of the <code>django-rest-framework</code> to provide some ReST functionality. The website and the rest functionality are all working fine.</p>
  
  <p>However there is one little problem: I need my API endpoints to point to a <strong>different subdomain</strong>.</p>
  
  <p>For example when a user visits the website he/she can navigate around normally according to my <code>urls.py</code>:</p>
  
  <pre><code>http://example.com/control_panel
  </code></pre>
  
  <p>So far so good.
  However when the API is used I want to change that to something more appropriate. So instead of <code>http://example.com/api/tasks</code> I need this to become:</p>
  
  <pre><code>http://api.example.com/tasks
  </code></pre>
  
  <p>How should I do that? </p>
  
  <p>Thanks in advance.</p>
  
  <p>P.S.
  The website will be running on Gunicorn with nginx serving as a reverse proxy.</p>