Wednesday, September 30, 2015

can't find static file

Hi all;

Stats:
Debian Linux 8 (jessie)
python = 2.7.9
Django 1.7 (To match tutorial)
sqlite data base
Using virtualenv

I'm working my way through the Tango With Rango tutorial and have hit a
snag. I added the static/images directory and put in a jpg photo for
data. The system can't find the file. I've tried the usual python
manage.py runserver and then used
/127.0.0.1:8000/static/images/P1000153.JPG which produces:

Request Method: GET
Request URL: http://127.0.0.1:8000/static/image/P1000153.JPG

'image/P1000153.JPG' could not be found

I tried the python manage.py findstatic. Same results. Below are my
project tree and my settings.py file. Probably a stupid error but I
can't find it.

├── db.sqlite3
├── __init__.py
├── manage.py
├── rango
│ ├── admin.py
│ ├── admin.pyc
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── migrations
│ │ ├── __init__.py
│ │ └── __init__.pyc
│ ├── models.py
│ ├── models.pyc
│ ├── tests.py
│ ├── urls.py
│ ├── urls.pyc
│ ├── views.py
│ └── views.pyc
├── static
│ ├── images
│ │ ├── __init__.py
│ │ └── P1000153.JPG
│ └── __init__.py
├── templates
│ ├── __init__.py
│ └── rango
│ ├── index.html
│ └── __init__.py
├── twr_project
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── settings.py
│ ├── settings.pyc
│ ├── urls.py
│ ├── urls.pyc
│ ├── wsgi.py
│ └── wsgi.pyc
└── twr_project.nja

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

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
TEMPLATE_PATH = os.path.join(BASE_DIR, 'templates')

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'u^y3v@)p)9m#z^1z194r$r$g%*(@v)@+@72uu#bu8&b2=!mpv$'

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

TEMPLATE_DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rango',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'twr_project.urls'

WSGI_APPLICATION = 'twr_project.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'America/Los_Angeles'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

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

STATIC_URL = '/static/'

SATATICFILES_DIRS = (
STATIC_PATH,
)
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or
# "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
TEMPLATE_PATH,
)




Thanks in advance

Gary R.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/560C4DCA.20205%40verizon.net.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment