When i run my app on localhost i try to show random banners configured using adzone, but when i load my home page i can't see the images that i used for the banners, the problem is that the path to the images is /media/adzone/bannerads/image.jpg , this path is automatically used by the app, and i cant change it. So how can i tell my app to look for images there?
My settings.py :
"""
Django settings for ciudad_tenis project.
For more information on this file, see
http://ift.tt/WG84IA
For the full list of settings and their values, see
http://ift.tt/1s34S5Z
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# Quick-start development settings - unsuitable for production
# See http://ift.tt/WG84IC
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '###############################################'
# 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',
'django.contrib.sites',
'news',
'tournaments',
'rules',
'finalists',
'courts',
'adzone',
)
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',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
# and add request if you didn't do so already
'django.core.context_processors.request',
'adzone.context_processors.get_source_ip',
)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
FACEBOOK_APP_ID = '1608874396001164'
FACEBOOK_APP_SECRET = 'd373e5da6c7ffd3788a310043484197d'
ROOT_URLCONF = 'ciudad_tenis.urls'
WSGI_APPLICATION = 'ciudad_tenis.wsgi.application'
# Internationalization
# http://ift.tt/WG863i
LANGUAGE_CODE = 'es'
TIME_ZONE = 'America/Argentina/Buenos_Aires'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Allow all host headers
ALLOWED_HOSTS = ['*']
# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'ciudad_tenis',
'HOST': '127.0.0.1',
'PORT': '3306',
'USER': 'root',
'PASSWORD': '',
}}
SITE_ID = '1'
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Allow all host headers
ALLOWED_HOSTS = ['*']
# Static asset configuration
import os
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
My urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
from news import views
from django.views.generic import TemplateView
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = patterns('',
# Examples:
url(r'^$', TemplateView.as_view(template_name='home.html'), name="home"),
# url(r'^blog/', include('blog.urls')),
url(r'^novedades/', include('news.urls', namespace="news")),
url(r'^admin/', include(admin.site.urls)),
url(r'^torneos/', include('tournaments.urls', namespace="tournaments")),
url(r'^reglas/', include('rules.urls', namespace="rules")),
url(r'^ganadores/', include('finalists.urls', namespace="finalists")),
url(r'^canchas/', include('courts.urls', namespace="fields")),
url(r'^adzone/', include('adzone.urls')),
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
My app structure:
myapp/
myapp/
static/
templates/
urls.py
settings.py
wsgi.py
__init__.py
adzone/
bannerads/
locale/
south_migrations/
templates/
templatestags/
models.py
urls.py
managers.py
admin.py
tests.py
views.py
other_app/
migrations/
static/
templates/
models.py
admin.py
urls.py
views.py
tests.py
__init__.py
Aucun commentaire:
Enregistrer un commentaire