title: OSError: [Errno 30] Read-only file system in Django on Heroku
body: <p>I'm using Django 2.0 and Heroku to host the application.</p>
  
  <p>My media directory settings are like</p>
  
  <p><strong><code>App/settings/production.py</code></strong>:</p>
  
  <pre><code>BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
  
  MEDIA_URL = '/media/'
  MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static_cdn', 'media_root')
  </code></pre>
  
  <p>I'm using gTTS to convert text to speech and save <code>.mp3</code> file in the media directory:</p>
  
  <pre><code>tts_file_name = str(int(time.time())) + '.mp3'
  joined_path = os.path.join(settings.MEDIA_ROOT, 'tts')
  joined_path_with_file = os.path.join(joined_path, tts_file_name)
  
  # create directory if does not exists
  if not os.path.exists(joined_path):
      os.makedirs(joined_path)
  
  tts = gTTS(text='Good morning', lang='en')
  tts.save(joined_path_with_file)
  
  # tts path to send to template
  tts_media_url = os.path.join(settings.MEDIA_URL, 'tts', tts_file_name)
  </code></pre>
  
  <p>It is working fine on local system as I can change file permissions manually also.</p>
  
  <p>But It is not working on Heroku and giving error:</p>
  
  <pre><code>OSError: [Errno 30] Read-only file system: '/static_cdn'
  </code></pre>
  
  <p>I tried to locate <code>static_cdn</code> by running <code>heroku shell</code>, but could not even found <code>static_cdn</code> in application path and root path. But it seems to be working as other uploading through form is working perfectly.</p>
  
  <p>using Django model's <code>upload_to</code> is working and even directory is created in <code>static_cdn</code>.</p>
  
  <p>How can I create directory in <code>static_cdn</code> on Heroku the same way Django does using model's <code>upload_to</code>?</p>