Hi,
-- 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 settings.py 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:
[project]/static
[project]/templates/static
[project]/[app]/static
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 manage.py 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
cat settings.py
# 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'}
AUTOLOAD_SITECONF = 'indexes'
SECRET_KEY = '[OMITTED, just in case]'
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.staticfiles',
'djangotoolbox',
'autoload',
'dbindexer',
# djangoappengine should come last, so it can override a few manage.py commands
'djangoappengine',
# Jason's apps
'blogtut',
# Core
'core',
)
MIDDLEWARE_CLASSES = (
# This loads the index definitions, so it has to come first
'autoload.middleware.AutoloadMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.request',
'django.core.context_processors.media',
'django.core.context_processors.static'
)
# 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'
STATICFILES_DIRS = (
"/home/[user]/[project]/myapp/templates/static",
"/home/[user]/[project]/myapp/blogtut/static")
STATIC_ROOT = '/home/[user]/[project]/myapp/static'
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder")
#ADMIN_MEDIA_PREFIX = '/media/admin/'
TEMPLATE_DIRS = (
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/'
LOGIN_REDIRECT_URL = '/'
ROOT_URLCONF = 'urls'
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment