Monday, December 17, 2012
Use media file in Django (CSS JS)
1. Specify the directory
STATICFILES_DIRS = (
os.path.join(os.path.dirname(__file__), 'template').replace('\\','/'),
.....
)
--------
2. Finder
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
----
3. Installed Apps
INSTALLED_APPS =(
....
'django.contrib.staticfiles',
....
)
-----
4. must use RequestContext
def test(request):
return render_to_response('base.html', context_instance=RequestContext(request))
5. {{STATIC_URL}}
<script type="text/javascript" src="{{ STATIC_URL }}js/JQUERY/query-1.8.3.min.js"></script>
<link href="{{ STATIC_URL }}css/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="{{ STATIC_URL }}css/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css">
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment