title: Open file in Django app
body: <p>I want to open a file from a Django app using <code>open()</code>. The problem is that <code>open()</code> seems to use whatever directory from which I run the <code>runserver</code> command as the root.</p>
  
  <p>E.g. if I run the server from a directory called foo like this</p>
  
  <pre><code>$pwd
  /Users/foo
  $python myapp/manage.py runserver
  </code></pre>
  
  <p><code>open()</code> uses <code>foo</code> as the root directory.</p>
  
  <p>If I do this instead</p>
  
  <pre><code>$cd myapp
  $pwd
  /Users/foo/myapp
  $python manage.py runserver
  </code></pre>
  
  <p><code>myapp</code> will be the root.</p>
  
  <p>Let's say my folder structure looks like this</p>
  
  <pre><code>foo/myapp/anotherapp
  </code></pre>
  
  <p>I would like to be able to open a file located at <code>foo/myapp/anotherapp</code> from a script also located at <code>foo/myapp/anotherapp</code> simply by saying</p>
  
  <pre><code>file = open('./baz.txt')
  </code></pre>
  
  <p>Now, depending on where I run the server from, I have to say either</p>
  
  <pre><code>file = open('./myapp/anotherapp/baz.txt')
  </code></pre>
  
  <p>or</p>
  
  <pre><code>file = open('./anotherapp/baz.txt')
  </code></pre>