Saturday, September 28, 2013

Re: Static files configuration

I can now access my CSS file and i've confirmed it's location by changing its name and confirming the dev server can't see it any more.after I change the file name.

The directory its finding it is under [project]/templates/static/css
Sorry, no idea why its working but I suspect its permissions based as i'm running udo python runserver
I think the dev server is only accessing files owned by root? It doesn't sound right though.

On Saturday, 28 September 2013 11:29:07 UTC-10, Jason S wrote:
I'm new to django and web development but have set up a project and run through a few python and django tuts.
I've gotten stuck importing CSS (and other static content) using the static settings available in the file and have attempted to resolve the issue by referring to a sample project and documentation and have ended up pretty confused.

I'd appreciate any help or thoughts and thanks in advance for taking the time to read and help with my issue.

I've ended up with a few "static" directories as follows:

Ideally all the static content for each app would be served from [project]/[app]/static and general static content from [project]/static
Please call this out if its not best practise, I've got to learn that as well!

I'm calling the static content using <link rel="stylesheet" href="{{ STATIC_URL }}css/test.css" /> and at one point I was able to locate the "test.css" file using python findstatic css/test.css in [project]/static/css/ but I've made too many changes to get back to it. I know I should be using git or similar to manage my changes, but one step at a time...

I've made alot of changes over about 4-5 hours, so I'd appreciate help correcting my config and tidying it so it performs as expected but also in removing any unnecessary components I've added. Note i've substituted some details, like the user and project name with [user] etc

# Initialize App Engine and import the default settings (DB backend, etc.).
# If you want to use a different backend you have to remove all occurences
# of "djangoappengine" from this file.
from djangoappengine.settings_base import *

import os
import os.path # from blogtut

# Activate django-dbindexer for the default database
DATABASES['native'] = DATABASES['default']
DATABASES['default'] = {'ENGINE': 'dbindexer', 'TARGET': 'native'}
#DATABASES['my_tumble_log'] = {'ENGINE': 'dbindexer', 'TARGET': 'native'}

SECRET_KEY = '[OMITTED, just in case]'


    # djangoappengine should come last, so it can override a few commands

    # Jason's apps

    # Core

    # This loads the index definitions, so it has to come first



# This test runner captures stdout and associates tracebacks with their
# corresponding output. Helps a lot with print-debugging.
TEST_RUNNER = 'djangotoolbox.test.CapturingTestSuiteRunner'

STATIC_URL = '/static'
STATIC_ROOT = '/home/[user]/[project]/myapp/static'


#ADMIN_MEDIA_PREFIX = '/media/admin/'
        os.path.join(os.path.dirname(__file__), 'templates'),
        os.path.join(os.path.realpath(__file__), '../templates'),

#MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media")
#MEDIA_URL = '/media/'
#IMAGE_URL = '/media/image/'

LOGIN_URL = '/login/'
LOGOUT_URL = '/logout/'


You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment