0

I cannot load JQuery no matter what I do! I did exactly what was suggested in this Question --> Load jQuery into Django but I dont want to use dynamic directories in my settings.py. Static directories are fine as this is just a personal project.

From Settings.py:

MEDIA_ROOT = '/usr/local/djcode/mysite/media/'

MEDIA_URL = 'http://<my ip address>/django/media/'

From my html file:

<script type="text/javascript" src="/mysite/media/jquery-1.2.6.js"></script>

When I go to this html file, it loads, but none of my JQuery functions work.

ADDITIONAL INFO: My website (urls.py, app folders, and media folder) are all in /usr/local/djcode/mysite/. The root url of my django website is http:///django/

Please Help!!!

3
  • And the problem is? What's the output? what did you try? I'm asking because what you are showing here is not what the answer in your link says you have to do. Commented Jul 16, 2011 at 2:41
  • I can load my html page fine, but none of my JQuery functions work. Commented Jul 16, 2011 at 2:42
  • Are you using the {{ MEDIA_URL }} var? what's the output in the browser for the script tag? Commented Jul 16, 2011 at 2:47

1 Answer 1

1

If your media url is "http://127.0.0.1/django/media" then the path of the file would be "http://127.0.0.1/django/media/jquery-1.2.6.js" Try just using your media url in the template:

<script type="text/javascript" src="{{ MEDIA_URL }}jquery-1.2.6.js"></script>
Sign up to request clarification or add additional context in comments.

4 Comments

That seemed to fix things, although I'm not sure I understand why. Why can't I use src="/mysite/media/jquer...."
Why should you be able to? That has nothing to do with the value you've defined for MEDIA_URL.
you can't use "/mysite/media/..." because you haven't configured anything to serve that url path.
django_dev_101: did this answer your question?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.