In addition you maybe need to add this to your settings.py:
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(PROJECT_ROOT, 'static'),
)
Where PROJECT_ROOT is a path to your project root dir.
BTW, maybe you will be interested in dajax and dajaxice.
2011/7/30 Amao Zhao <amaozhao@gmail.com>
Hi,vevanin. Django 1.3 updated the staticfiles server, you should use STATIC_URS to replace your MEDIA_URL in your template.
在 2011年7月31日星期日,vevanin@yandex.ru <vevanin@yandex.ru> 写道:
> I don't understand how can I use jquery with Django.
> I made a template:
> <html>
> <head>
> <title>test</title>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> <script type="text/javascript" src="{{ MEDIA_URL }}js/
> jquery-1.6.1.min.js"></script>
> </head>
> <body>
> <script type="text/javascript">
> $("<div><p>hello!</p></div>").appendTo("#testid");
> </script>
> <div id="main">
> <div id="testid">
> <p>test</p>
> </div>
> </div>
> </body>
> </html>
>
> In settings.py file I wrote: MEDIA_URL = '/static/'
> There is a 'static/js' folder in my application folder, and it has a
> jquery-1.6.1.min.js in it.
> This doesn't work. Could anyone help me?
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
> --
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment