0

Try as I might, and after trying to read through and follow these (and others): How do I serve CSS to Django in development? Django not loading CSS?

I still can't get any staticfiles served by django. at this point, I have a project called limbo, with a yet-to-be-dev'd app called limbo (that was a bad idea, I no realize...name confusion), and a separate app called polls, where I followed well-known django tutorial to build out the app, then added a little session variable passing to pass the name to a stupid output on the target of the form. It's all served on EC2 linux AMI, with django v1.10, I'm viewing it with chrome v53. some code excertps are below, but the repos are public (one for the bulk of the django, the other for the html templates)

~/limbo/limbo/settings.py:

ROOT_URLCONF = 'limbo.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [
        '/var/www/html/',
        '/var/www/html/polls/',
    ],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]
...
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/

#STATIC_URL = '/static/'
#STATIC_ROOT = os.path.join(BASE_DIR, "/var/www/html/static/")

STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = [
#   "/home/ec2-user/limbo/limbo/static/",
]

STATICFILES_FINDERS = [ 
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

~/limbo/limbo/urls.py:

from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^polls/', include('polls.urls')),
    url(r'^admin/', admin.site.urls),
]

entire ~/limbo/polls/urls.py

from django.conf.urls import url

from . import views

urlpatterns = [
        url(r'^index.html$', views.index, name='index'),
        url(r'^formTest$', views.testForm, name='testForm'),
        url(r'^name-test.html$', views.get_name, name='getName'),
        url(r'^testFormResults/',
                # <string>[\w\-]+)/$',
                views.testFormResults,
                name='showFormResults'),
]

excerpt from /var/www/html/polls/name.html (which shows fine, but without any css nor img), it does show both when viewing local on my win8.1 surface, but not remotely from the server (note I now have {% load static %} instead and it didn't change anything that I can see):

<!DOCTYPE html>
<html>
    {% load staticfiles %} 
<head>
    <!--this group for local use w/o django-->
    <link rel="stylesheet" type="text/css" href="../static/polls/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../static/polls/css/bootstrap-theme.min.css">
    <link rel="stylesheet" type="text/css" href="../static/polls/css/limbo.css">
    <!--this group for use w/ django-->
    <link rel="stylesheet" type="text/css" href="{% static 'polls/css/bootstrap.min.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'polls/css/bootstrap-theme.min.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'polls/css/limbo.css' %}" />
</head>
<div class="navbar navbar-default navbar-fixed-top"> 
    <div class=container> 
        <img class="top-bar" src="static/polls/limbo-clipart-1.jpg" alt="limbo graphic"/>
        <img src="{% static 'polls/static/limbo-clipart-1.jpg' %}" alt="limbo graphic"/>
        <h1>This is a heading</h1>
    </div>
</div>

Try as I might, I just can't get past this. I'm excited about getting django up and running as I think it'll be a fantastic way to build the api I need and the little bit of browser-based UI the project needs, but I need a little css to make the browser-UI.

Community
  • 1
  • 1
Keith
  • 777
  • 8
  • 27
  • I didn't thoroughly read your question, but you should use `{% load static %}` instead of `{% load staticfiles %}` for django 1.10. check this; http://stackoverflow.com/questions/34422971/load-static-and-load-staticfiles-which-is-preferred – Leonard2 Oct 10 '16 at 10:02
  • @Leonard2, thanks for the suggestion. I tried it, but am still not getting any styling. – Keith Oct 10 '16 at 13:54

0 Answers0