I'm in desperate need of help. I have followed many tutorials, as well as scrutinized this, this, this, and this article. I was getting error messages when following the Django documentation for static servers mentioned in the middle two articles, but I seem to be doing all the right things discussed in the two regarding settings.py, placing jquery.js in the correct directory and referencing the correct source in the actual html file.
My media directory seems to be being referenced - the css file in there is working splendidly, and if I go to http://127.0.0.1:8000/media/jquery.js, the jquery file is displayed.
Still, none of my functions that I've built after following multiple tutorials work for me on my django project. I've been banging my head against the wall for days - please help if you can.
Django App Project File:
__init__.py
data.db
javascript_app/
manage.py
media/
settings.py
templates/
urls.py
views.py
Javascript App Directory:
__init__.py
admin.py
models.py
tests.py
urls.py
views.py
Media Directory:
jquery.js
style_js.css
Templates Directory:
javascript_app/
base.html
note_list.html
In my main settings file:
import os.path
ROOT_PATH = os.path.dirname(__file__)
...
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media")
MEDIA_URL = 'http://127.0.0.1:8000/media/'
ADMIN_MEDIA_PREFIX = '/media/admin/'
In my main urls file:
from django.conf.urls.defaults import *
from django.views.static import *
from django.conf import settings
...
urlpatterns = patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT }),
Desperately, I also put a media reference in my javascript_app 's urls.py (with the above-referenced import commands as well):
urlpatterns = patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT }),
In templates/javascript/base.html:
<head>
<title>{% block title %}Notes Application{% endblock %}</title>
<link rel="stylesheet" href="/media/style_js.css">
<script type="text/javascript" src="/jennystanchak/media/jquery.js"></script>
</head>
And finally in templates/javascript/note_list.html:
{% extends "javascript/base.html" %}
{% block content %}
...
<script>
// my script here
</script>
{% endblock %}
What in the configuration am I missing??
Thank you SO MUCH in advance for your help :)
-- An aspiring female programmer