title: django file upload: [Errno 13] Permission denied: '/static'
body: <p>I am trying to upload several files in django. On my local maching where I use the djangos build in server everything works fine but on my productivity server I get this error:</p>
  
  <pre><code>[Errno 13] Permission denied: '/static'
  </code></pre>
  
  <p>There are many questions about this issue but nothing I found worked for me.
  In my case it has nothing to do with file permissions. I found out that the problem is that django want save the files in the root folder of my filesystem and not in the root folder of my website. If I create the folder in '/static' the files will be created there but images for example are not shown on the webpage because django expects them in '/var/www/webpage-root/static/...'</p>
  
  <p>I use a model to store files:</p>
  
  <pre><code>class Document(models.Model):
      title = models.CharField(max_length=100, blank=True, null=False)
      document = models.FileField(upload_to='static/bachelor/documents/', max_length=500, blank=True, null=True)
  </code></pre>
  
  <p>and save them in this way:</p>
  
  <pre><code>if form.is_valid():
      data = request.FILES['document']
      doc = Document(document=data)
      doc.save()
  </code></pre>
  
  <p>As described there: <a href="https://docs.djangoproject.com/en/dev/topics/http/file-uploads/" rel="noreferrer">https://docs.djangoproject.com/en/dev/topics/http/file-uploads/</a></p>
  
  <p>I use Apache and mod_wsgi. The apache file looks like this:</p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
      ServerAdmin user@webpage.de
      ServerName webpage.de
      ServerAlias www.webpage.de
      DocumentRoot /var/www/webpage
  
      Alias /media /var/www/webpage/webpage/
      Alias /static /var/www/webpage/static/
  
      &lt;Directory /var/www/webpage&gt;
          Order allow,deny
          Allow from all
      &lt;/Directory&gt;
  
      WSGIScriptAlias / /var/www/webpage/apache/webpage.wsgi
      &lt;Directory /var/www/webpage&gt;
              Options Indexes FollowSymLinks MultiViews
              AllowOverride None
              Order allow,deny
              allow from all
      &lt;/Directory&gt;
  
      ErrorLog ${APACHE_LOG_DIR}/webpage-error.log
  
      # Possible values include: debug, info, notice, warn, error, crit,
      # alert, emerg.
      LogLevel warn
  
      CustomLog ${APACHE_LOG_DIR}/webpage-access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>The settings file of my website:</p>
  
  <pre><code># Absolute filesystem path to the directory that will hold user-uploaded files.
  # Example: "/var/www/example.com/media/"
  MEDIA_ROOT = ''
  
  # URL that handles the media served from MEDIA_ROOT. Make sure to use a
  # trailing slash.
  # Examples: "http://example.com/media/", "http://media.example.com/"
  MEDIA_URL = ''
  
  # Absolute path to the directory static files should be collected to.
  # Don't put anything in this directory yourself; store your static files
  # in apps' "static/" subdirectories and in STATICFILES_DIRS.
  # Example: "/var/www/example.com/static/"
  STATIC_ROOT = ''
  
  # URL prefix for static files.
  # Example: "http://example.com/static/", "http://static.example.com/"
  STATIC_URL = '/static/'
  
  # Additional locations of static files
  STATICFILES_DIRS = (
      '/var/www/website/static/',
      '/home/michael/Development/website/static/',
      # Put strings here, like "/home/html/static" or "C:/www/django/static".
      # Always use forward slashes, even on Windows.
      # Don't forget to use absolute paths, not relative paths.
  )
  
  # List of finder classes that know how to find static files in
  # various locations.
  STATICFILES_FINDERS = (
      'django.contrib.staticfiles.finders.FileSystemFinder',
      'django.contrib.staticfiles.finders.AppDirectoriesFinder',
      # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
  )
  </code></pre>
  
  <p>I had to set two different paths in STATICFILES_DIRS because I already had problems to serve static files on my server. With this two lines I can serve static files on both ends, on my development machine and my public server runnig apache.</p>
  
  <p>Did I miss something in my configuration or is there something wrong? I dont know why apache wants upload the files in /static instead of /var/www/website/static but I think it can be because of a problem with my apache configuration...</p>
  
  <p>Has anyone an idea or can help me please?</p>
  
  <p>Thank you much</p>