Django: can't load static files from template using Ubuntu 14.04/Django Droplet

Hello everyone, I’m trying to render a template page with my Django project running on a Ubuntu 14.04 Droplet, but I’m having a lot of issues loading static files from the template.

My project structure:


Here it is my nginx configuration file:

upstream app_server {
    server fail_timeout=0;

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    root /usr/share/nginx/html;
    index index.html index.htm;

    client_max_body_size 4G;
    server_name _;

    keepalive_timeout 5;

    # Your Django project's media files - amend as required
    location /media  {
        alias /home/workspace/app-toscana/django/djangoapptoscana/djangoapptoscana/media;

    # your Django project's static files - amend as required
    location /static {
        #alias /home/workspace/app-toscana/django/djangoapptoscana/djangoapptoscana/static;
        alias /home/workspace/app-toscana/django/djangoapptoscana/static;

    # Proxy the static assests for the Django Admin panel
    location /static/admin {
       alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server;

The settings file:


Django settings for djangoapptoscana project.

For more information on this file, see

For the full list of settings and their values, see

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))

# Quick-start development settings - unsuitable for production
# See

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '0^rkr0-u%ic)yo^qc()vp8ii&mn&irk+ie_o=swp7qd82ervyh'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True



# Application definition



ROOT_URLCONF = 'djangoapptoscana.urls'

WSGI_APPLICATION = 'djangoapptoscana.wsgi.application'

# Database

    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'test',
        'USER': 'test',
        'PASSWORD': 'test',
        'HOST': 'localhost',
        'PORT': '',

# Internationalization



USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)


#STATIC_PATH = os.path.join(BASE_DIR, 'static')

STATIC_ROOT = '/home/workspace/app-toscana/django/djangoapptoscana/static/'

STATIC_URL = '/static/' # You may find this is already defined as such.


Template page:

{% load staticfiles %}
<!DOCTYPE html>
    <meta charset="UTF-8">
    <title>AdminLTE 2 | Dashboard</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <!-- Bootstrap 3.3.4 -->
    <link href="{% static 'bootstrap/css/bootstrap.min.css' %}" rel="stylesheet" type="text/css" />
    <!-- Font Awesome Icons -->
    <link href="" rel="stylesheet" type="text/css" />
    <!-- Ionicons -->
    <link href="" rel="stylesheet" type="text/css" />
    <!-- jvectormap -->
    <link href="{% static 'plugins/jvectormap/jquery-jvectormap-1.2.2.css' %}" rel="stylesheet" type="text/css" />
    <!-- Theme style -->
    <link href="{% static 'dist/css/AdminLTE.css' %}" rel="stylesheet" type="text/css" />
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link href="{% static 'dist/css/skins/_all-skins.min.css' %}" rel="stylesheet" type="text/css" />

    <link href="{% static 'dist/css/ol.css' %}" rel="stylesheet" type="text/css" />
    <script src="{% static 'dist/js/ol.js' %}"></script>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src=""></script>
        <script src=""></script>
        <div>Hello world!</div>

When I try to get some static file, I receive a 404 error. Any suggestion? I tried different configuration without any results. Thanks!

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

This comment has been deleted

I tried it but still go the same error. I am using v 1.11. Anyone knows some issue with this?

This was the solution to my problem too, Thanks for updating!