New Django App MEDIA_URL pathing incorrect
Question: So, I've created a new app in Django via `python manage.py startapp foo`

My new app will not load any files in the `/site_media/` directory, via the
`{{ MEDIA_URL }}`. They are attempting to path from the App's directory, not
the `/site_media/` directory.

* * *

**Example:** Instead of loading from
`http://sitename/site_media/bootstrap/bootstrap.min.css`

it tries to load from `http://sitename/foo/bootstrap/bootstrap.min.css`

* * *

Here is a snippet from the `settings.py` which defines the `MEDIA_URL`

    
    
    MEDIA_URL = '/site_media/'
    

I can force the files to load correctly in the app by replacing `{{ MEDIA_URL
}}` with `/site_media/` in the `base.html` and my `show_foo.html`, but this
then breaks the pathing on the rest of the site.

I'm not sure what else anyone would like to see to try and diagnose the issue,
but I'm stumped!

* * *

Just in case: from `urls.py` in my app directory

    
    
    #!/usr/bin/python
    # -*- coding: UTF8 -*-
    from django.conf.urls.defaults import *
    
    urlpatterns = patterns('foo_web.foo_track.views',   
    url('^$','view_foo_track',name='foo_home'),  
    url('^newentry/(?P<entry_id>\d+)$','write_form_data',name='foo_track_new'),
    )
    

* * *

`settings.py` edit*removed comments for readability

    
    
    import os
    current_dir = os.path.abspath(os.path.dirname(__file__))
    from os import sys, path
    sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
    import run_server
    
    cherry_config,django_config = run_server.get_web_server_parameters()
    DEBUG = django_config['DEBUG']
    TEMPLATE_DEBUG = django_config['TEMPLATE_DEBUG']
    CACHE_MODE = django_config['CACHE_MODE']
    DB = django_config['DB']
    HOST = django_config['HOST']
    
    
    LOGIN_URL = '/'
    LOGOUT_URL = '/'
    
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2', 
            'NAME': '%s' % DB,             
            'USER': 'postgres', 
            'PASSWORD': '*****',
            'HOST': '%s' % HOST,
            'PORT': '5432',              
        }
    }
    
    CACHES = {
        'default': {
            'BACKEND': CACHE_MODE,
            'LOCATION': 'my_cache_table',
            'TIMEOUT': 1800,
            'OPTIONS': {
                'MAX_ENTRIES': 10000
            }
        }
    }
    
    ADMINS = (
        ('**', '**'),
    )
    
    MANAGERS = ADMINS
    
    #~ EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    DEFAULT_FROM_EMAIL = '**' 
    SERVER_EMAIL = '**' 
    EMAIL_USE_TLS = True
    EMAIL_HOST = "**"
    EMAIL_HOST_USER = "**"
    EMAIL_HOST_PASSWORD = "**"
    
    TIME_ZONE = 'America/Chicago'
    
    LANGUAGE_CODE = 'en-us'
    
    #~ gettext = lambda s: s
    #~ LANGUAGES = (
        #~ ('de', gettext('German')),
        #~ ('en', gettext('English')),
    #~ )
    
    SITE_ID = 1
    
    USE_I18N = True
    
    USE_L10N = True
    
    USE_TZ = True
    
    MEDIA_ROOT = current_dir + '/media/'
    
    MEDIA_URL = '/site_media/'
    
    STATIC_ROOT = current_dir + '/media/static/'
    
    STATIC_URL = '/site_static/'
    
    STATICFILES_DIRS = (
        # Put strings here, like "/home/html/static" or "C:/www/django/static".
    )
    
    STATICFILES_FINDERS = (
        'django.contrib.staticfiles.finders.FileSystemFinder',
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
    )
    
    SECRET_KEY = '***'
    
    if DEBUG:
        TEMPLATE_LOADERS = (
            'django.template.loaders.filesystem.Loader',
            'django.template.loaders.app_directories.Loader',
        #     'django.template.loaders.eggs.Loader',
        )    
    else:
        TEMPLATE_LOADERS = (
            ('django.template.loaders.cached.Loader', (
            'django.template.loaders.filesystem.Loader',
            'django.template.loaders.app_directories.Loader',
            )),
        #     'django.template.loaders.eggs.Loader',
        )
    
    MIDDLEWARE_CLASSES = (
        'django.middleware.common.CommonMiddleware',
        'django.contrib.sessions.middleware.SessionMiddleware',
        'django.middleware.csrf.CsrfViewMiddleware',
        'django.contrib.auth.middleware.AuthenticationMiddleware',
        'django.contrib.messages.middleware.MessageMiddleware',
        'sensei_web.middleware.FilterPersistMiddleware',
        # Uncomment the next line for simple clickjacking protection:
        # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
        #~ 'sensei_web.middleware.ProfileMiddleware'
    
        #~ 'django.middleware.cache.UpdateCacheMiddleware',
        #~ 'django.middleware.common.CommonMiddleware',
        #~ 'django.middleware.cache.FetchFromCacheMiddleware',
    )
    
    ROOT_URLCONF = 'sensei_web.urls'
    
    WSGI_APPLICATION = 'sensei_web.wsgi.application'
    
    TEMPLATE_DIRS = (
        current_dir + '/templates',
    
    )
    
    INSTALLED_APPS = (
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.sites',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        # Uncomment the next line to enable the admin:
         'django.contrib.admin',
        # Uncomment the next line to enable admin documentation:
        # 'django.contrib.admindocs',
        'foo.foo',
        'foo.foo',
        #~ 'foo.foo',
        'foo.foo',
        'foo.foo',
        'foo',
       'foo.foo',
       'foo.foo_track',
        )
    
    ACCOUNT_ACTIVATION_DAYS = 7
    
    LOGGING = {
        'version': 1,
        'disable_existing_loggers': False,
        'filters': {
            'require_debug_false': {
                '()': 'django.utils.log.RequireDebugFalse'
            }
        },
        'handlers': {
            'mail_admins': {
                'level': 'ERROR',
                'filters': ['require_debug_false'],
                'class': 'django.utils.log.AdminEmailHandler'
            }
        },
        'loggers': {
            'django.request': {
                'handlers': ['mail_admins'],
                'level': 'ERROR',
                'propagate': True,
            },
        }
    }
    


Answer: Thanks everyone for the help! It turns out this is just a mistake I made :(
Very interesting consequences though.

I noticed something funny in the logs about `A (% csrf_token %) was used in a
template, but the context did not provide the value. This is uaually caused by
not using RequestContext.`

Lo and behold, in my `views.py` this line was incorrect: `return
render_to_response('foo_track/foo_track_show.html',{'access':access})`

it should have had the `RequestContext(request)` as well like this: `return
render_to_response('foo_track/foo_track_show.html',{'access':access},RequestContext(request))`

And now everything works. Sheesh!

