title: Django Nginx Gunicorn - Media Files Not Showing (DigitalOcean Deployment)
body: <p>I have deployed a Django project on Ubuntu 16.04 with Nginx and Gunicorn. I have gotten everything, including the static files but my media files will not serve properly.</p>
  
  <p>settings.py</p>
  
  <pre><code>MEDIA_URL = '/media/'
  
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>resume_upload = models.FileField(blank=False, upload_to='resumes', null=True, validators=[FileExtensionValidator(allowed_extensions=['pdf']), validate_file_size])
  </code></pre>
  
  <p>What I have listed in /etc/nginx/sites-available/ is</p>
  
  <pre><code>server {
  listen 80;
  server_name website.com www.website.com ;
  
  location = /favicon.ico { access_log off; log_not_found off; }
  location /static/ {
      root /home/syed/btawebsite;
  }
  
  location = /media/ {
      root /home/syed/btawebsite;
  }
  
  location / {
      include proxy_params;
      proxy_pass http://unix:/home/syed/myproject.sock;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I would like go on the admin, click on the uploaded file and be able to view the file in the browser. Anyone have any ideas on how I can achieve this? I have verified through using the terminal and looking through the directories that the files are in fact adding to ~btawebsite/media/resumes but I am unable to view them when I click the admin url.</p>
  
  <p>When I click on that url I get an error:</p>
  
  <p>Not Found
  The requested resource was not found on this server.</p>
  
  <p><strong>Update:</strong> </p>
  
  <p>I have changed settings.py to</p>
  
  <pre><code>STATIC_URL = '/static/'
  
  STATICFILES_DIRS = (
      os.path.join(BASE_DIR, 'static/'),
  )
  
  STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
  
  MEDIA_URL = '/media/'
  
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
  </code></pre>
  
  <p>And nginx settings to </p>
  
  <pre><code>location /static/ {
      alias /home/syed/btawebsite/static/;
  }
  
  location = /media/ {
      alias /home/syed/btawebsite/media/;
  }
  </code></pre>
  
  <p>Static is still working, however, media is not.</p>